Calling custom SOAP methods
This section outlines how a client can call the methods exposed by the SOAP service.
Let us assume your 'SoapService' is published on the localhost with port number 8011.
WSDL
WSDL stands for Web Services Description Language. It's an XML-based format that describes the functionalities and operations of web services. Think of it as a blueprint or specification that tells clients how to interact with a web service.
The client can obtain the WSDL by calling the published 'SoapService' service by opening the URL below in e.g. the web browser:
http://localhost:8011/SoapService?wsdl
The WSDL of the 'SoapService' service looks like:
<?xml version='1.0' encoding='UTF-8'?>
<!-- Published by JAX-WS RI (https://github.com/eclipse-ee4j/metro-jax-ws). RI's version is JAX-WS RI 3.0.2 git-revision#91dd558. -->
<!-- Generated by JAX-WS RI (https://github.com/eclipse-ee4j/metro-jax-ws). RI's version is JAX-WS RI 3.0.2 git-revision#91dd558. -->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
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://service.usoft.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://service.usoft.com/"
name="SoapServiceService">
<types>
<xsd:schema>
<xsd:import namespace="http://service.usoft.com/"
schemaLocation="http://localhost:8011/SoapService?xsd=1"/>
</xsd:schema>
</types>
<message name="SoapMethod">
<part name="parameters"
element="tns:SoapMethod"/>
</message>
<message name="SoapMethodResponse">
<part name="parameters"
element="tns:SoapMethodResponse"/>
</message>
<message name="Exception">
<part name="fault"
element="tns:Exception"/>
</message>
<portType name="SoapService">
<operation name="SoapMethod">
<input wsam:Action="http://service.usoft.com/SoapService/SoapMethodRequest"
message="tns:SoapMethod"/>
<output wsam:Action="http://service.usoft.com/SoapService/SoapMethodResponse"
message="tns:SoapMethodResponse"/>
<fault message="tns:Exception"
name="Exception"
wsam:Action="http://service.usoft.com/SoapService/SoapMethod/Fault/Exception"/>
</operation>
</portType>
<binding name="SoapServicePortBinding"
type="tns:SoapService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
<operation name="SoapMethod">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="Exception">
<soap:fault name="Exception"
use="literal"/>
</fault>
</operation>
</binding>
<service name="SoapServiceService">
<port name="SoapServicePort"
binding="tns:SoapServicePortBinding">
<soap:address location="http://localhost:8011/SoapService"/>
</port>
</service>
</definitions>
Importing the WSDL
Subsequently the client can import the WSDL in a client .NET or Java framework or in a tool for web service testing.
Calling a SOAP method
The client can call the 'SoapMethod' method of the published 'SoapService' service by posting a web request to the URL below:
http://localhost:8011/SoapService
The web request of type POST contains an XML body structured like the example shown below. The XML contains a sample message with ID 515 for a non-existent company named XYX.
Please check that the USoft namespace specifies an XML element named 'usoft:SoapMethod' that corresponds to the name of the 'SoapMethod' method of the 'SoapService' method.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:usoft="http://service.usoft.com/"
xmlns:ns0="www.xyz.com/">
<soapenv:Header/>
<soapenv:Body>
<usoft:SoapMethod>
<ns0:Message>
<ns0:Header>
<ns0:MessageID>515</ns0:MessageID>
</ns0:Header>
</ns0:Message>
</usoft:SoapMethod>
</soapenv:Body>
</soapenv:Envelope>
The 'SoapService' service returns the web response listed below.
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<S:Body>
<ns0:SoapMethodResponse xmlns:ns0="http://service.usoft.com/"/>
</S:Body>
</S:Envelope>
You can check the successful handling of the POST web request by inspecting the file 'UService.log' in the subfolder 'logs' of the folder where the 'SoapService' service has been published. Here you will find the debug message included in your 'SoapMethod' method implementation.