Understanding Java Web Services JAX-WS and WSDL

Try my tutorial: Build a Java web service in five minutes located here.

It would be helpful if you run that example.

A JAX-WS Java Web Service Conversation.

In this real example, this is the actual text of the conversation that occurs in my jax-ws tutorial.
The client here is connecting to localhost, port 8081. The Web service of course, is on localhost, listening at that port.

All blank lines are the real blank lines. I can't explain the numbers that delineate the XML, but that's what really happened in the conversation.

(I hope your browser renders this correctly). There is a blank line at the end of each partie’s conversation in the 1st, 2nd, and 4th part, but not the 3rd.

A JAX-WS Java Web Service Conversation.
------Client --------------------------------------------------
GET /dostuff?wsdl HTTP/1.1
User-Agent: Java/1.6.0_20
Host: localhost:8081
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive

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

------Server --------------------------------------------------
HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: text/xml;charset="utf-8"

609
<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --><definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/&quot; xmlns:tns="http://abc/&quot; xmlns:xsd="http://www.w3.org/2001/XMLSchema&quot; xmlns="http://schemas.xmlsoap.org/wsdl/&quot; targetNamespace="http://abc/&quot; name="DoStuffService">
<types>
<xsd:schema>
<xsd:import namespace="http://abc/&quot; schemaLocation="http://localhost:8081/dostuff?xsd=1"></xsd:import&gt;
</xsd:schema>
</types>
<message name="squareMe">
<part name="parameters" element="tns:squareMe"></part>
</message>
<message name="squareMeResponse">
<part name="parameters" element="tns:squareMeResponse"></part>
</message>
<portType name="DoStuff">
<operation name="squareMe">
<input message="tns:squareMe"></input>
<output message="tns:squareMeResponse"></output>
</operation>
</portType>
<binding name="DoStuffPortBinding" type="tns:DoStuff">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http&quot; style="document"></soap:binding>
<operation name="squareMe">
<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="DoStuffService">
<port name="DoStuffPort" binding="tns:DoStuffPortBinding">
<soap:address location="http://localhost:8081/dostuff"></soap:address&gt;
</port>
</service>
</definitions>
0

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

------Client --------------------------------------------------
POST /dostuff HTTP/1.1
Content-type: text/xml;charset="utf-8"
Soapaction: ""
Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
User-Agent: JAX-WS RI 2.1.6 in JDK 6
Host: localhost:8081
Connection: keep-alive
Content-Length: 186

<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:squareMe xmlns:ns2="http://abc/"><arg0>11.0</arg0></ns2:squareMe></S:Body></S:Envelope&gt;
----------------------------------------------------------------

------Server --------------------------------------------------
5e
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body&gt;
71
<ns2:squareMeResponse xmlns:ns2="http://abc/"><return>121.0</return></ns2:squareMeResponse></S:Body></S:Envelope&gt;
0

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

Advertisements

About SunKing2

Former web developer, guitar player, started Piano 2012 -yes still doing it! Recovery, sobriety, mental health advocate.
This entry was posted in java, Uncategorized, web services. Bookmark the permalink.

One Response to Understanding Java Web Services JAX-WS and WSDL

  1. What should I do if I see this:
    Unsupported Content-Type: text/html;charset=utf-8 Supported ones are: [text/xml]
    Thankyou in advance

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s