Making SOAP Requests from DataDirect XQuery™

DataDirect can use the ddtek:wscall() function to make SOAP requests. For instance, we might want to look up a book on Amazon.com using the ISBN of the book. The following function creates the payload for the web message we want to send.

declare function local:amazon-listing($isbn)
{
    <tns:Request>
      <tns:Condition>All</tns:Condition>
      <tns:DeliveryMethod>Ship</tns:DeliveryMethod>
      <tns:FutureLaunchDate/>
      <tns:IdType>ASIN</tns:IdType>
      <tns:ISPUPostalCode/>
      <tns:MerchantId/>
      <tns:OfferPage/>
      <tns:ItemId>{ $isbn }</tns:ItemId>
      <tns:ResponseGroup>Medium</tns:ResponseGroup>
      <tns:ReviewPage/>
      <tns:SearchIndex/>
      <tns:SearchInsideKeywords/>
      <tns:VariationPage/>
    </tns:Request>
};

Now we can use the following query to create the message payload by calling our function, then use ddtek:wscall() to invoke the web service and get the result, which is a description of the book whose ISBN we are sending:

let $loc :=
  <ddtek:location 
    address="http://soap.amazon.com/onca/soap?Service=AWSECommerceService" 
	soapaction="http://soap.amazon.com" />
let $payload := local:amazon-listing("0395518482")
return ddtek:wscall($loc, $payload)
PrevNext
XML ConvertersIDE Support

Copyright © 1993 - 2008. Progress Software Corporation. All rights reserved. | N. America: 800 876 3101 | World: +44 (0) 1753 218 930