Modifications to XML files
This section describes changes to the XML and WSDL files required to add a custom handler. The sample custom handler works with complex data rather than simple strings. Therefore, the changes described here should be preceded by those described in the complex data example. Those modifications result in two deployment descriptors: one for client and one for server.
Modification of the web service deployment descriptor
The deployment descriptors are ‘SstWSInsurancePolicyServerInterface.xml’and ‘SstWSInsurancePolicyClientInterface.xml’.
Service deployment descriptor
Add the following XML to the service deployment descriptors after the < wsdlUrls> section and before the < service > tag.
<handlers namespace="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface">
<handler name="QueryString" class="SstWSSampleBusinessPartnerVerifyHandler"/>
</handlers>
Add the following operation after the operation getInfoForPolicy in the service’s operations
rpc 
<operation name="getInfoForPolicy:"
qName="swsipi:getInfoForPolicyWithVerification"></operation>
document literal 
<operation flow="doclit:docLitExampleHandler"
name="getInfoForPolicy:"
qName="swsipi:getInfoForPolicyWithVerification"></operation>
 
Client deployment descriptor
Add the following operation after the operation getInfoForPolicy in the service’s operations
rpc 
<operation name="getInfoForPolicy:withVerification:"
qName="swsipi:getInfoForPolicyWithVerification">
</operation>
Document literal 
<operation flow="doclit:docLitExampleHandler"
name="getInfoForPolicy:"
qName="swsipi:getInfoForPolicyWithVerification">
</operation>
This concludes changes needed to the deployment descriptor common to the client and server. Write the changes to SstWSInsurancePolicyClientInterface.xml and SstWSInsurancePolicyServerInterface.xml.
Modifying the Web Service Location
The high level concrete definition of the web service is found in ‘SstWSInsurancePolicyInterface.wsdl’.
Notice the following line which associates the concrete definition of the interface to the lower level interface definition.
<import
namespace="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface-interface"
location="SstWSInsurancePolicyInterface-interface.wsdl"/>
The line in ‘SstWSInsurancePolicyInterface.wsdl’ which locates the web servlet is .
<soap:address location="http://vasthost:7374/SstWSServlet"/>
.If you are not able to change your hosts file, it is sufficient to change ‘vasthost’ ‘localhost’ or the IP address of the server machine. Notice the port number, 7374. When the web service is deployed, a servet is automatically started to handle the web service requests (a POST). This web servlet runs on port 7374 and is separate from the web service. Clients will be sending their HTTP requests to the SstWSServlet.
Refining Web Service Type Definitions
As a short review, the basic structure of the interface definition (SstWSInsurancePolicyInterface-interface.wsdl) is
Definition imports namespaces into the definition including the XMLSchema which holds very basic types;
Types section includes schema(s) for the interface;
List of messages whose internal structure is dictated by the SOAP style of the web service;
Port definition defines input and output messages for each web service operation;
Binding defines soap actions for each web service operation.
Changes to the types schema and additional messages support the sample custom handler. In order to add messages, the port and binding definitions also change.
Definitions
For the rpc style the tin namespace needs to be changed:
rpc 
In the definitions tag, change
xmlns:tin="urn:SstWSInsurancePolicyInterface"
to
xmlns:tin="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
 
Types
For the document literal style, it is necessary to change message elements defined in the types section:
Document Literal  
<xsd:schema targetNamespace="urn:SstWSInsurancePolicyInterface"
xmlns:ins="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
schemaLocation="http://vasthost:63001/SstWSInsurancePolicyInterface.xsd" />
...
<xsd:element name="getInfoForPolicy" type="xsd:string"/>
<xsd:element name="getInfoForPolicyResponse" type="ins:SstPolicyOrError"/>
<xsd:element name="getInfoForPolicyWithVerification" type="xsd:string"/>
<xsd:element name="PolicyOrError" type="ins:SstPolicyOrError"/>
<xsd:element name="QueryString" type="xsd:string"/>
</xsd:schema>
The existing operation getInfoForPolicy must return an insurance policy or an error
Next, add a second schema to the types section.
Rcp schema 
<xsd:schema targetNamespace="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
schemaLocation="SstWSInsurancePolicyInterface.xsd" />
</xsd:schema>
Document Literal schema 
<xsd:schema targetNamespace="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
schemaLocation="SstWSInsurancePolicyInterface.xsd" />
<xsd:element name="getInfoForPolicyWithVerification" type="xsd:string"/>
</xsd:schema>
Messages
Alter the message getInfoForPolicyResponse to reflect the bold text. The existing operation getInfoForPolicy must return an insurance policy or an error.
Rpc 
<message name="getInfoForPolicyResponse">
<part name="outMsg" type="tin:SstPolicyOrError"/>
</message>
Document 
The corresponding alteration takes place in a schema element in the <types> section
A new operation, getInfoForPolicyWithVerification, triggers the handler. The following two messages must be added to the web service definition
getInfoForPolicyWithVerification
getInfoForPolicyWithVerificationResponse
 
Rpc 
<message name="getInfoForPolicyWithVerification">
<part name="getInfoForPolicy" type="xsd:string"/>
<part name="QueryInfoIn" element="tin:QueryString"/>
</message>
<message name="getInfoForPolicyWithVerificationResponse">
<part name="outMsgInfo" type="tin:SstPolicyOrError"/>
<part name="QueryInfoOut" element="tin:QueryString"/>
</message>
QueryInfoIn and QueryInfoOut are encoded as SOAP headers. Add these two messages after the getInfoForPolicyResponse operation.
document literal 
<message name="getInfoForPolicyWithVerification">
<part name="Vbody" element="swsipi:getInfoForPolicyWithVerification"/>
<part name="Vheader" element="tin:QueryString"/>
</message>
<message name="getInfoForPolicyWithVerificationResponse">
<part name="RBody" element="tin:PolicyOrError"/>
<part name="RHeader" element="tin:QueryString"/>
</message>
The additional elements support the new operation, getInfoForPolicyWithVerification . Vheader and RHeader are encoded as SOAP headers.
Port Type
The new messages must appear as new operations in the port type definition.
<operation name="getInfoForPolicyWithVerification">
<input message="tns:getInfoForPolicyWithVerification"/>
<output message="tns:getInfoForPolicyWithVerificationResponse"/>
</operation>
Binding
Here is the binding for the new operation getInfoForPolicyWithVerification . Notice the presence of a SOAP header as well as the SOAP body.
rpc  
<operation name="getInfoForPolicyWithVerification">
<soap:operation soapAction="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface-interface/getInfoForPolicy"/>
<input>
<soap:body use="encoded"
parts="getInfoForPolicy"
namespace="urn:SstWSInsurancePolicyInterface"
encodingStyle="encoded"/>
<soap:header use="literal"
namespace="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
message="tns:getInfoForPolicyWithVerification"
part="QueryInfoIn"/>
</input>
<output>
<soap:body use="encoded"
parts="outMsgInfo"
namespace="urn:SstWSInsurancePolicyInterface"
encodingStyle="encoded"/>
<soap:header use="literal"
namespace="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
message="tns:getInfoForPolicyWithVerificationResponse"
part="QueryInfoOut"/>
</output>
</operation>
For rpc encoded style, the SOAP body encodingStyle should be "http://schemas.xmlsoap.org/soap/encoding/" or "encoded"; for rpc literal, the encodingStyle should be "literal".
document literal 
<operation name="getInfoForPolicyWithVerification">
<soap:operation soapAction="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface-interface/getInfoForPolicy"/>
<input>
<soap:body use="literal"
parts=" Vbody"/>
<soap:header use="literal"
message="tns:getInfoForPolicyWithVerification"
part=" Vheader"/>
</input>
<output>
<soap:body use="literal"
parts="RBody"/>
<soap:header use="literal"
message="tns:getInfoForPolicyWithVerificationResponse"
part="RHeader"/>
</output>
</operation>
For document literal style, the SOAP body use should be "literal" and the encodingStyle should be absent.
This concludes the changes to the web service definition. Write the changes to ‘SstWSInsurancePolicyInterface-interface.wsdl’.
 
Last modified date: 08/16/2019