Eu preciso validar o acesso em um servidor PHP. Vou validar com os dados transmitidos pelo cabeçalho pelo cliente. Mas estou tendo muitos problemas para fazer isso: eu estou usando javax. Este é o meu wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://localhost/test/ws"
xmlns:tns="http://localhost/test/ws"
xmlns:su="http://localhost/test/ws" >
<types>
<xsd:schema targetNamespace="http://localhost/test/ws" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:su="http://localhost/test/ws">
<xsd:element name="serverRequest" type="xsd:string"></xsd:element>
<xsd:element name="serverResponse" type="xsd:string"></xsd:element>
<xsd:element name="authenticaUserHeader" type="su:authenticaHeader"></xsd:element>
<xsd:complexType name="authenticaHeader">
<xsd:sequence>
<xsd:element name="user" type="xsd:string" minOccurs="1"> </xsd:element>
<xsd:element name="passworld" type="xsd:string" minOccurs="1"> </xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</types>
<message name="dataRequest">
<part name="data" element="su:serverRequest" />
</message>
<message name="dataResponse">
<part name="return" element="su:serverResponse" />
</message>
<message name="authenticaHeader">
<part name="authentica" element="su:authenticaUserHeader" />
</message>
<portType name="runPortType">
<operation name="runSoapServer">
<input message="tns:dataRequest" name="dataRequest" />
<output message="tns:dataResponse" name="dataResponse" />
</operation>
</portType>
<binding name="runBinding" type="tns:runPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="runSoapServer">
<soap:operation soapAction="" />
<input>
<soap:body use="literal"></soap:body>
<soap:header message="tns:authenticaHeader" part="authentica" use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="runService">
<port name="runSoap" binding="tns:runBinding">
<soap:address location="http://localhost/test/ws?wsdl"></soap:address>
</port>
</service>
</definitions>
Para gerar as classes a partir do WSDL eu usei o comando wsimport e essas são as classes geradas:
Gostaria antes de processar os dados no servidor, enviar os dados via cabeçalho para o servidor. Como eu faço isso?
Para conectar-se ao servidor, criei uma classe chamada Cliente dessa forma:
package wsservice;
public class Client {
public static void main(String[] args) {
RunService runService = new RunService();
RunPortType runPortType = runService.getRunSoap();
String data = "Hello Wolrd";
String resposta = runPortType.runSoapServer(data);
System.out.println(resposta);
}
}