O'Reilly logo

Java and SOAP by Robert Englander

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.1. SOAP Messaging

The format of the SOAP envelope for messaging services differs from the format used for RPC services. There is no concept of a method signature, method parameters, or return values in the messaging model. Basically, you're just sending some XML to a service. However, there are some requirements that allow you to direct the message to the correct service and service method. The name of the first child element of the SOAP Body must correspond to the name of the service method to be used, and the xmlns namespace attribute on that element specifies the name of the service. Here's a simple SOAP message that is directed to the recordTemperature method of the urn:WeatherDiary service for processing:

<SOAP_ENV:Envelope 
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
      <recordTemperature xmlns="urn:WeatherDiary"/>
      <temperature>75.5</temperature>
      <zipcode>50328</zipcode>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The recordTemperature service method records the current temperature associated with a zip code. Notice that there's no data in the recordTemperature element, although it's perfectly valid for that element to contain data and child elements. The point is that it isn't required. In fact, I could have made the temperature and zipcode elements children of recordTemperature instead of siblings. Either way is fine; as far as SOAP is concerned, this is just a message that is delivered to a method, not an RPC with arguments that need to be handled ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required