Search code examples
javaweb-serviceswsdljax-ws

How to call JAX-WS method from URL


I have a local web service and I can call its methods using a JAVA client.

Is it possible to access its methods using a URL ? I can access the wsdl XML using this URL:

http://localhost:9999/ws/hello?wsdl

And I would like to call a method like such:

http://localhost:9999/ws/hello/getHelloWorldAsString?name=test

But I am receiving errors "Localhost did not send any data".

Is there a way to do this ?


Solution

  • As far as I was aware Jax-ws uses POST to receive calls. You will have to build an XML request to POST to your URL. Something like this:

    POST /ws/hello HTTP/1.1
    SOAPAction: ""
    Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2,   */*; q=.2
    Content-Type: text/xml; charset=utf-8
    User-Agent: Java/1.6.0_13
    Host: localhost:9999
    Connection: keep-alive
    Content-Length: 224
    
    <?xml version="1.0" ?>
    <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
        <S:Body>
            <ns2:getHelloWorldAsString xmlns:ns2="http://ws.mkyong.com/">
                <arg0>test</arg0>
            </ns2:getHelloWorldAsString>
        </S:Body>
    </S:Envelope>