[Lab-Analysis] Creating a Soap Web Service Bottoms Up Using Java SE Endpoint Publisher

We will further analyze the lab excercise done @ http://javajee.com/lab-creating-a-soap-web-service-bottoms-up-using-endp....

 

Service Endpoint Interface (SEI)

We had used the below SEI for creating the web service:

package com.javajee.ws.tsexample1;

@WebService
public interface TimeService
{
         @WebMethod
         String getTimeFromServer();
}

 

Looking into the Generated WSDL

 

Generated WSDL

<definitions 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utili...
xmlns:wsp="http://www.w3.org/ns/wspolicy
xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/
xmlns:tns="http://tsexample1.ws.javajee.com/
xmlns:xsd="http://www.w3.org/2001/XMLSchema
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://tsexample1.ws.javajee.com/
name="TimeServiceImplService">

<types>

<xsd:schema>

<xsd:import namespace="http://tsexample1.ws.javajee.com/schemaLocation="http://127.0.0.1:8888/ts?xsd=1"/>

</xsd:schema>

</types>

<message name="getTimeFromServer">

<part name="parameters" element="tns:getTimeFromServer"/>

</message>

<message name="getTimeFromServerResponse">

<part name="parameters" element="tns:getTimeFromServerResponse"/>

</message>

<portType name="TimeService">

<operation name="getTimeFromServer">

<input wsam:Action="http://tsexample1.ws.javajee.com/TimeService/getTimeFromServerRequest
          message="tns:getTimeFromServer"/>

<output wsam:Action="http://tsexample1.ws.javajee.com/TimeService/getTimeFromServerResponse
          message="tns:getTimeFromServerResponse"/>

</operation>

</portType>

<binding name="TimeServiceImplPortBinding" type="tns:TimeService">

<soap:binding transport="http://schemas.xmlsoap.org/soap/httpstyle="document"/>

<operation name="getTimeFromServer">

<soap:operation soapAction=""/>

<input>

<soap:body use="literal"/>

</input>

<output>

<soap:body use="literal"/>

</output>

</operation>

</binding>

<service name="TimeServiceImplService">

<port name="TimeServiceImplPort" binding="tns:TimeServiceImplPortBinding">

<soap:address location="http://127.0.0.1:8888/ts"/>

</port>

</service>

</definitions>

 

Looking into SOAP request and SOAP response

You can look into the SOAP request and response with many tools such as TCPMon or wireshark. We will be using TCPMon here to make things simple.

Steps to configure TCP Mon

  1. Run build\tcpmon.bat form the tcpmon home folder (extracted folder).

  2. Go to the Admin tab

    1. Add listening port as 9999

    2. Give the target host name and target port as per your publisher

    3. Click add

  3. Next, change the client code to change the port from 8888 to 9999.

  4. Compile and execute the client code.

  5. Verify the results in the tcpmon tab for port 9999:

    • There will be 2 requests and 2 responses:

      1. First a GET request is made to get the wsdl

      2. Server sends back the WSDL

      3. Client makes another request with the SOAP request

      4. Server sends back the SOAP response.

 

NOTE! You may also use a tool such as SOAP UI to create a SOAP request and send it to server.

 

Requests (HTTP Requests with SOAP message)

GET /ts?wsdl HTTP/1.1
User-Agent: Java/1.8.0_60
Host: 127.0.0.1:9999
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive

POST /ts HTTP/1.1
Accept: text/xml, multipart/related
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tsexample1.ws.javajee.com/TimeService/getTimeFromServerRequest"
User-Agent: JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e
Host: 127.0.0.1:9999
Connection: keep-alive
Content-Length: 209

<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:getTimeFromServer xmlns:ns2="http://tsexample1.ws.javajee.com/"></ns2:getTimeFromServer></S:Body></S:Envelope>

 

Response (HTTP Response with SOAP message)

HTTP/1.1 200 OK
Date: Tue, 20 Oct 2015 04:45:27 GMT
Transfer-encoding: chunked
Content-type: text/xml;charset=utf-8

8cd
<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. --><!-- Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. --><definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utili..." xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://tsexample1.ws.javajee.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tsexample1.ws.javajee.com/" name="TimeServiceImplService">
<types>
<xsd:schema>
<xsd:import namespace="http://tsexample1.ws.javajee.com/" schemaLocation="http://127.0.0.1:9999/ts?xsd=1"></xsd:import>
</xsd:schema>
</types>
<message name="getTimeFromServer">
<part name="parameters" element="tns:getTimeFromServer"></part>
</message>
<message name="getTimeFromServerResponse">
<part name="parameters" element="tns:getTimeFromServerResponse"></part>
</message>
<portType name="TimeService">
<operation name="getTimeFromServer">
<input wsam:Action="http://tsexample1.ws.javajee.com/TimeService/getTimeFromServerRequest" message="tns:getTimeFromServer"></input>
<output wsam:Action="http://tsexample1.ws.javajee.com/TimeService/getTimeFromServerResponse" message="tns:getTimeFromServerResponse"></output>
</operation>
</portType>
<binding name="TimeServiceImplPortBinding" type="tns:TimeService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
<operation name="getTimeFromServer">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal"></soap:body>
</input>
<output>
<soap:body use="literal"></soap:body>
</output>
</operation>
</binding>
<service name="TimeServiceImplService">
<port name="TimeServiceImplPort" binding="tns:TimeServiceImplPortBinding">
<soap:address location="http://127.0.0.1:9999/ts"></soap:address>
</port>
</service>
</definitions>
0

HTTP/1.1 200 OK
Date: Tue, 20 Oct 2015 04:45:27 GMT
Transfer-encoding: chunked
Content-type: text/xml; charset=utf-8

10e
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:getTimeFromServerResponse xmlns:ns2="http://tsexample1.ws.javajee.com/"><return>Tue Oct 20 10:15:27 IST 2015</return></ns2:getTimeFromServerResponse></S:Body></S:Envelope>
0

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!