How to build WSDL Request body

Viewed 16

I wrote a minimalistic Web Service in Java using JAX-WS. The Service provides an interface

@WebMethod
@WebResult(partName = "return")
@Action(input = "http://api.example.org/TimeService/getTimeAsStringRequest", output = "http://api.example.org/TimeService/getTimeAsStringResponse")
public String getTimeAsString();

The service provider is working correctly.

http://127.0.0.1:9876/ts?wsdl

gives me the following responese:

<definitions targetNamespace="http://impl.be.example.org/" name="TimeServiceImplService">
    <import namespace="http://api.example.org/" location="http://127.0.0.1:9876/ts?wsdl=1"/>
    <binding name="TimeServiceImplPortBinding" type="ns1:TimeService">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
    <operation name="getTimeAsString">
        <soap:operation soapAction=""/>
        <input>
            <soap:body use="literal" namespace="http://api.example.org/"/>
        </input>
        <output>
            <soap:body use="literal" namespace="http://api.example.org/"/>
        </output>
    </operation>
    <operation name="getTimeAsElapsed">
        <soap:operation soapAction=""/>
        <input>
            <soap:body use="literal" namespace="http://api.example.org/"/>
        </input>
        <output>
            <soap:body use="literal" namespace="http://api.example.org/"/>
        </output>
    </operation>
    </binding>
    <service name="TimeServiceImplService">
        <port name="TimeServiceImplPort" binding="tns:TimeServiceImplPortBinding">
            <soap:address location="http://127.0.0.1:9876/ts"/>
        </port>
    </service>
</definitions>

http://127.0.0.1:9876/ts?wsdl=1 gives me the following response:

<definitions targetNamespace="http://impl.be.example.org/" name="TimeServiceImplService">
    <import namespace="http://api.example.org/" location="http://127.0.0.1:9876/ts?wsdl=1"/>
    <binding name="TimeServiceImplPortBinding" type="ns1:TimeService">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
    <operation name="getTimeAsString">
        <soap:operation soapAction=""/>
        <input>
            <soap:body use="literal" namespace="http://api.example.org/"/>
        </input>
        <output>
            <soap:body use="literal" namespace="http://api.example.org/"/>
        </output>
    </operation>
    <operation name="getTimeAsElapsed">
        <soap:operation soapAction=""/>
        <input>
            <soap:body use="literal" namespace="http://api.example.org/"/>
        </input>
        <output>
            <soap:body use="literal" namespace="http://api.example.org/"/>
        </output>
    </operation>
    </binding>
    <service name="TimeServiceImplService">
        <port name="TimeServiceImplPort" binding="tns:TimeServiceImplPortBinding">
            <soap:address location="http://127.0.0.1:9876/ts"/>
        </port>
    </service>
</definitions>

How can I access the service directly via HTML call? How can I build the XML body for the request from the information above?

PS:

POST http://127.0.0.1:9876/ts?wsdl HTTP/1.0
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?>
   <soapenv:Envelope 
   xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:tns="http://www.4d.com/namespace/default">
   <soapenv:Body>
      <ns1:getTimeAsString xsi:type="xsd:any">
      </ns1:getTimeAsString>
   </soapenv:Body>
</soapenv:Envelope>

terminates with the following error: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[6,47]

Regards Michael

0 Answers
Related