Creating SOAP transactions with the *SOAP API

From PxPlus

Jump to: navigation, search

Contents

How to generate a Simple Object Access Protocol (SOAP) transaction

SOAP transactions take many formats and will need to be customized for the site and service you are attempting to communicate with.

Here is a sample from www.w3.org that we will generate using *SOAP in pxplus.

Sample SOAP Transaction

  <?xml version="1.0"?>
  <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
   soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
  <soap:Body xmlns:m="http://www.example.org/stock"> 
    <m:GetStockPrice>
      <m:StockName>IBM</m:StockName>
    </m:GetStockPrice>
  </soap:Body> 
  </soap:Envelope>

Sample PxPlus Program

 bf$=""
    * Clear variable 
 CALL "*soap;Init",bf$
    * Initiate process by adding beginning XML/SOAP headers:
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
         xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
 CALL "*soap;Method",bf$,"GetStockPrice",""
    * Start method that will be the main request
    <GetStockPrice >
    </GetStockPrice>
 CALL "*soap;AddValue",bf$,"StockName","PVXPLUS"
    * Add the information to the method
    <StockName>PVXPLUS</StockName>
 CALL "*soap;Finalize",bf$
    * End the transaction
    </soap:Body>
    </soap:Envelope>
 CALL "*soap;Exchange",bf$,"https://www.example.com/stock",response$
    * Process the transaction and return the response.

Sample generated request

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
  <GetStockPrice >
   <StockName>PVXPLUS</StockName>
  </GetStockPrice>
</soap:Body>
</soap:Envelope>

Sample generated response

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
 soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> 
<soap:Body xmlns:m="http://www.example.org/stock">
  <m:GetStockPriceResponse>
    <m:Price>34.5</m:Price>
  </m:GetStockPriceResponse>
</soap:Body>
</soap:Envelope>
Personal tools