mn8 Language Reference | Index    

SOAPClient

SUMMARY: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTORS SUMMARY  NO OPERATORS  METHODS SUMMARYDETAIL: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTOR DETAILS  NO OPERATORS  METHOD DETAILS

Description

Simple SOAP client concept

Usage

Simple example using an echo service and looking for the transaction faults.

    $ser typeof Series
    $ser.add("Helo World!!!")
    $s = SOAPClient.create("http://nagoya.apache.org:5049/axis/services/echo")
    $r = $s.execute("http://soapinterop.org/", "echoString", $ser)
    if $s.isFault then [
      print $s.getError/details]
    print $r

This request will produce the following SOAP XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

      <SOAP-ENV:Body>
        <ns1:echoString xmlns:ns1="http://soapinterop.org/">
          <arg0 xsi:type="xsd:string">Hello World!</arg0>
        </ns1:echoString>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
  

Simple example using the Google search service with parameters in Map.

    $map typeof Map
    $map.add("key", "YOUR DEVELOPER KEY HERE!!!")
    $map.add("q", "Antal Attila atech")
    $map.add("start", 0)
    $map.add("maxResults", 10)
    $map.add("filter", true)
    $map.add("restrict", "")
    $map.add("safeSearch", false)
    $map.add("lr", "")
    $map.add("ie", "latin1")
    $map.add("oe", "latin1")

    $s = SOAPClient.create("http://api.google.com/search/beta2")
    $r = $s.execute("urn:GoogleSearch", "doGoogleSearch", $map)

    if $s.isFault then [
       print $s.getError/message]
    print $r

This request will produce the following SOAP XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

      <SOAP-ENV:Body>
        <ns1:doGoogleSearch xmlns:ns1="urn:GoogleSearch/">
          <key xsi:type="xsd:string">YOUR DEVELOPER KEY HERE!!!</key>
          <q xsi:type="xsd:string">Antal Attila atech</q>
          <start xsi:type="xsd:int">0</start>
          <maxResults xsi:type="xsd:int">10</maxResults>
          <filter xsi:type="xsd:boolean">true</filter>
          <restrict xsi:type="xsd:string"/>
          <safeSearch xsi:type="xsd:boolean">false</safeSearch>
          <lr xsi:type="xsd:string"/>
          <ie xsi:type="xsd:string">latin1</ie>
          <oe xsi:type="xsd:string">latin1</oe>
        </ns1:dooGoogleSearch>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
  

Simple example using the Google search service with parameters in Series.

    $ser typeof Series
    $ser.add("YOUR DEVELOPER KEY HERE!!!")
    $ser.add("Antal Attila atech")
    $ser.add(0)
    $ser.add(10)
    $ser.add(true)
    $ser.add("")
    $ser.add(false)
    $ser.add("")
    $ser.add("latin1")
    $ser.add("latin1")

    $s = SOAPClient.create("http://api.google.com/search/beta2")
    $r = $s.execute("urn:GoogleSearch", "doGoogleSearch", $ser)

    if $s.isFault then [
       print $s.getError/message]
    print $r

This request will produce the following SOAP XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

      <SOAP-ENV:Body>
        <ns1:doGoogleSearch xmlns:ns1="urn:GoogleSearch/">
          <arg0 xsi:type="xsd:string">YOUR DEVELOPER KEY HERE!!!</arg0>
          <arg1 xsi:type="xsd:string">Antal Attila atech</arg1>
          <arg2 xsi:type="xsd:int">0</arg2>
          <arg3 xsi:type="xsd:int">10</arg3>
          <arg4 xsi:type="xsd:boolean">true</arg4>
          <arg5 xsi:type="xsd:string"></arg5>
          <arg6 xsi:type="xsd:boolean">false</arg6>
          <arg7 xsi:type="xsd:string"></arg7>
          <arg8 xsi:type="xsd:string">latin1</arg8>
          <arg9 xsi:type="xsd:string">latin1</arg9>
        </ns1:dooGoogleSearch>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
  

Simple example using the Amazon search service. Attention for all Amazon services need to use the setDataType method!

    $map typeof Map
    $map.setConceptLabel("KeywordSearchRequest")
    $map.add("keyword", "Cruise")
    $map.add("page", "1")
    $map.add("mode", "books")
    $map.add("tag", "webservices-20")
    $map.add("type", "lite")
    $map.add("devtag", "YOUR DEVELOPER KEY HERE!!!")
    $map.add("format", "xml")
    $map.add("version", "1.0")

    $s = SOAPClient.create("http://soap.amazon.com/onca/soap")
    $s.setDataType("m:KeywordRequest")
    $r = $s.execute("urn:PI/DevCentral/SoapService", "KeywordSearchRequest", $map)

    if $s.isFault then [
       print $s.getError]
    print $r

This request will produce the following SOAP XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

      <SOAP-ENV:Body>
        <ns1:KeywordSearchRequest xmlns:ns1="urn:PI/DevCentral/SoapService">   
          <KeywordSearchRequest xsi:type="m:KeywordRequest">                     
                 <keyword>Cruise</keyword>                                        
                 <page>1</page>                                                
                 <mode>books</mode>                                             
                 <tag>webservices-20</tag>                                     
                 <type>lite</type>                                             
                 <devtag>YOUR DEVELOPER KEY HERE!!!</devtag>                               
                 <format>xml</format>                                          
                 <version>1.0</version>                                        
          </KeywordSearchRequest>                                                
        </ns1:KeywordSearchRequest>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
  

Version: 0.1
Authors:Antal Attila ()
Location:
Inherits: Concept

Constructor List

create (String )
top

Method List

Stringexecute (String , String , Concept )
SOAPErrorgetError
LogicalisFault
setDataType (String )
setEncodingStyle (String )
top
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI

Detailed Constructor Info

create (String )
Parameters:
:SOAP endpoint URL
Exceptions:
badURLException :
(Error)
If the URL is not valid.

Creates and instatiates the SOAP concept with the endpoint URL

top

Detailed Method Info

execute (String , String , Concept )
Parameters:
:The operation (method) name namspace
:The method name
: Concept with parameters. You can use here a SeriesConcept (all parameter elements will have the label named arg0..argX) or MapConcept (all parameter elements will have the label named Map->Element->Ket value). If using other Concept then Series or Map will be invoked the concept's toXML method.
Returns: String
Exceptions:
connectionException :
(Error)
If unable to connect to SOAP server

Executes a SOAP requests.

top
getError
Returns: SOAPError

Is the SOAP transaction is faulted this method returns the SOAP error concept.

top
isFault
Returns: Logical

Is the SOAP transaction faulted it will returns true, in the other case false.

top
setDataType (String )
Parameters:
:String parameter to specify the request data type attribute
Returns:

If your SOAP request message use data types specifyed on the server side you need to set the data type attribute (see the usage)

top
setEncodingStyle (String )
Parameters:
:Encoding namespace attribute value
Returns:

If your encoding style attribute (SOAP-ENV:encodingStyle) is different than the default encoding (http://schemas.xmlsoap.org/soap/encoding/) you can set it other.

top