Copyright © 2005, Molsoft LLC Nov 24 2008
|
To access some external services there is a protocol called SOAP. Now ICM can send the SOAP request to get result back to ICM. Sending request to the SOAP server A SOAP request is special XML text which contains :
In ICM you can form a SOAP message using SoapMessage function. It creates a special soapMessage object which holds SOAP method name and it's arguments. Example: # create a message with SOAP method and a namespace req = SoapMessage( "doSpellingSuggestion","urn:GoogleSearch" ) # add method arguments req = SoapMessage( req, "key","btnHoYxQFHKZvePMa/onfB2tXKBJisej" ) # get key from google req = SoapMessage( req, "pharse", "Bretney Spers" ) # some misspelled pharse Once message is ready it can be send to the server using read http command. read string s_soapServiceURL + " " + String( soapMessage ) The result of the server response will be stored into s_out variable. It can be parsed to soapMessage object using SoapMessage function.
HTTP.postContentType = "text/xml" read string "http://api.google.com/search/beta2" + " " + String(req) res = SoapMessage( s_out ) if Error(res) == "" then # process message endif Processing SOAP results To get the result from the SOAP message Value function is applied to the result soapMessage. In some cases the result returned by SOAP server is actually some complex data structure (not just a single string or number). In such cases you may navigate through this structure using index expressions: soapObject[ i_integerIndex ] or soapObject[ s_stringIndex ] For example the following code navigates through the result obtained from the google search service.
res = Value( SoapMessage( s_out ) )
s_html = ""
s_html += "Searched web for <b>" + res["searchQuery"] + "</b>. Search took " + res["searchTime"] + " seconds.<br>"
elements = res["resultElements"]
for i=1,Nof(elements)
resElement = elements[i]
s_html += "<br>"
cat = String( resElement["directoryCategory"]["fullViewableName"] )
summary = String( resElement["summary"] )
title = String( resElement["title"] )
snippet = String( resElement["snippet"] )
url = String( resElement["URL"] )
cachedSize = String( resElement["cachedSize"] )
if (Length(title) != 0) then
s_html += "<font color=\"#0000FF\"><b><u>" + title + "</u></b></font><br>"
else
s_html += "<font color=\"#0000FF\"><b><u>" + url + "</u></b></font><br>"
endif
if (Length(snippet) != 0) s_html += snippet + "<br>"
if (Length(summary) != 0) s_html += "<font color=\"#808080\">Description:</font> " + summary + "<br>"
if (Length(cat) != 0) s_html += "<font color=\"#808080\">Category: <u>" + cat + "</u></font><br>"
if (Length(title) != 0) s_html += "<font color=\"#008000\"><u>" + url + "</u> - " + cachedSize + "</font><br>"
endfor
Related functions: SoapMessage Value Error Nof
|
| Copyright© 1989-2004, Molsoft,LLC - All Rights Reserved. This document contains proprietary and confidential information of Molsoft, LLC. The content of this document may not be disclosed to third parties, copied or duplicated in any form, in whole or in part, without the prior written permission from Molsoft, LLC. |