SOAP taglib ver. 1.6

    Custom JSP taglib. Lets you execute SOAP over HTTP requests and prepare SOAP messages. Body tag SOAPrequest executes SOAP over HTTP request. You must set target URL and SOAPaction as parameters for this tag. Body for this tag will be interpreted as an envelope for SOAP message. Body tags SOAPmessage, SOAPheaders and SOAPbody help you to prepare SOAP response.

For example (currency exchange service on http://www.xmethods.net):
 


<%@ taglib uri="taglib.tld" prefix="do" %>

<do:SOAPrequest url="http://services.xmethods.net:80/soap" action="getRate">

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/1999/XMLSchema">
 <SOAP-ENV:Body>
  <ns1:getRate xmlns:ns1="urn:xmethods-CurrencyExchange" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <country1 xsi:type="xsd:string">US</country1>
    <country2 xsi:type="xsd:string">Russia</country2>
  </ns1:getRate>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

</do:SOAPrequest>



in this example tag will print the following output:
 

<?xml version="1.0" encoding="UTF-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <soap:Body>
  <n:getRateResponse xmlns:n="urn:xmethods-CurrencyExchange">
   <Result xsi:type="xsd:float">29.153</Result>
  </n:getRateResponse>
 </soap:Body>
</soap:Envelope>

SOAP response can be saved also in the page scope variable (type is String) for the future processing:
 


<%@ taglib uri="taglib.tld" prefix="do" %>

<do:SOAPrequest url="http://services.xmethods.net:80/soap" action="getRate" id="A">

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/1999/XMLSchema">
 <SOAP-ENV:Body>
  <ns1:getRate xmlns:ns1="urn:xmethods-CurrencyExchange" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <country1 xsi:type="xsd:string">US</country1>
    <country2 xsi:type="xsd:string">Russia</country2>
  </ns1:getRate>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

</do:SOAPrequest>
Result is:<%=A%>

Tag SOAPmessage helps you to compose messages. For example, the above mentioned data might looks like so:
 


<%@ taglib uri="taglib.tld" prefix="do" %>

<do:SOAPmessage>

  <ns1:getRate xmlns:ns1="urn:xmethods-CurrencyExchange" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <country1 xsi:type="xsd:string">US</country1>
    <country2 xsi:type="xsd:string">Russia</country2>
  </ns1:getRate>

</do:SOAPmessage>

You may define also header and body for message. For example:
 


<%@ taglib uri="taglib.tld" prefix="do" %>

<do:SOAPmessage>

 <do:SOAPheaders uri="http://acme.com/headers">
   <do:SOAPheader name="header1" mandatory="true">value for header1</do:SOAPheader>
   <do:SOAPheader name="header2">value for header2</do:SOAPheader>
 </do:SOAPheaders>

 <do:SOAPbody>
  <ns1:getRate xmlns:ns1="urn:xmethods-CurrencyExchange" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <country1 xsi:type="xsd:string">US</country1>
    <country2 xsi:type="xsd:string">Russia</country2>
  </ns1:getRate>
 </do:SOAPbody>

</do:SOAPmessage>

Tags are:

SOAPrequest

Executes SOAP over HTTP request. Parameters are:

1) url target URL.
2) action describes SOAP action.
3) method describes SOAP method
4) id Optional parameter, describes page scope String variable. Without this variable result of request will be printed, otherwise it will be saved in this variable.
5) asynch Execution mode. Possible values are true or false. Default value is false. If you set this value to true SOAP request will be executed in the separate thread.

SOAPmessage

Body tag. Wraps own body into envelope stuff. Parameters are: none

SOAPheaders

Body tag. Interprets own body as a header section for SOAP message. You may use this tag within SOAPmessage. Parameters are:

1) uri URI for namespace

SOAPheader

Body tag. Interprets own body as an individual header for SOAP message. You may use this tag within SOAPheaders. Parameters are:

1) name name for header
2) mandatory Optional parameter with possible values true or false. Describes header's status (mustUnderstand attribute).

SOAPbody

Body tag. Interprets own body as a body for SOAP message. You may use this tag within SOAPmessage. Parameters are: none
 

for downloading:

    Library: soaptag.jar    Description: taglib.tld

© Coldbeans Software      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.