users@jax-ws.java.net

Errors consuming a PHP Based Web service through JAX-WS

From: Sergio Gutierrez <saguti_at_gmail.com>
Date: Tue, 7 Nov 2006 19:18:07 -0500

Thanks Jitu for your answer.

The text I pasted onto the message was the whole exception I was getting,
but I tried using JAX-WS 2.1, and the exception did not appear anymore.

But, right now I am facing another problem. I wrote a simple Web Service,
with a method that receives a string and returns a string; I am not having
problems with the invocation, but I am receiving a null response.

This is the traces obtained so far:

WSDL: (Web Service written with PHP NuSOAP; the WSDL is auto-generated)

<!-- ---- WSDL Begins ----------- -->


<?xml version="1.0" encoding="ISO-8859-1"?>
<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:tns="urn:hellowsdl"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="urn:hellowsdl">
<types><xsd:schema targetNamespace="urn:hellowsdl">
 <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
 <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
</xsd:schema>
</types>
<message name="helloRequest">
    <part name="name" type="xsd:string"/>
</message>

<message name="helloResponse">
    <part name="return" type="xsd:string"/>
</message>

<portType name="hellowsdlPortType">
    <operation name="hello">
        <documentation>Says hello to the caller</documentation>
        <input message="tns:helloRequest"/>
        <output message="tns:helloResponse"/>
    </operation>
</portType>

<binding name="hellowsdlBinding" type="tns:hellowsdlPortType">
    <soap:binding style="rpc" transport="
http://schemas.xmlsoap.org/soap/http"/>
    <operation name="hello">
        <soap:operation soapAction="urn:hellowsdl#hello" style="rpc"/>
        <input>
            <soap:body use="literal" namespace="urn:hellowsdl"/>
        </input>
        <output>
            <soap:body use="literal" namespace="urn:hellowsdl"/>
        </output>
    </operation>
</binding>

<service name="hellowsdl">
    <port name="hellowsdlPort" binding="tns:hellowsdlBinding">
        <soap:address location="http://calumma.une.net.co/ws/hello.php"/>
    </port>
</service>
</definitions>


<!-- ---- WSDL Ends ----------- -->

SOAP Request sent from my JAX-WS Client:

<!-- Request Begins ------------ -->
POST /ws/hello.php HTTP/1.1

SOAPAction: urn:hellowsdl#hello

Content-Type: text/xml; charset="utf-8"

Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *;
q=.2, */*; q=.2

User-Agent: Java/1.5.0_06

Host: calumma.une.net.co

Connection: keep-alive

Content-Length: 184

<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:hello xmlns:ns2="urn:hellowsdl">
            <name>Sergio</name>
        </ns2:hello>
    </S:Body>
</S:Envelope>

<!-- Request Ends ------------ -->


---------------------
SOAP Response as received from the PHP NuSOAP Web Service

<!-- Response Begins ------------ -->

HTTP/1.1 200 OK
Date: Tue, 07 Nov 2006 23:56:33 GMT
Server: Apache/1.3.36 (Unix) PHP/5.1.4 mod_ssl/2.8.27 OpenSSL/0.9.8b
X-Powered-By: PHP/5.1.4
X-SOAP-Server: NuSOAP/0.7.2 (1.94)
Content-Length: 480
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/xml;
charset=ISO-8859-1

<?xml version="1.0" encoding="ISO-8859-1"?>
    <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/" 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/">
    <SOAP-ENV:Body>
        <helloResponse xmlns="urn:hellowsdl">
            <return>Hello, Sergio</return>
        </helloResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

<!-- Response Ends -->

------------------------
The code I am using is the following (I paste only the main method of the
class):

    public static void main(String[] args)
    {
        Hellowsdl servicio = new Hellowsdl();
        HellowsdlPortType port = servicio.getHellowsdlPort();

        String name = "Sergio";

        String resp = port.hello(name);

        System.out.println("Answer is: " + resp);
    }


-------------------

Is worth to say that when I use document/literal style, I receive another
exception, so I did not try anymore with that style.

Thanks in advance for your help and attention.

Sorry for sending so much information.

Kind regards.

Sergio G.