A Question about using SOAP in REALbasic

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SpreadTooThin

    A Question about using SOAP in REALbasic

    Not sure if this is the appropriate place to ask a question about
    soap.
    If you think you know a better news group to discuss this please
    point
    me there.
    I wrote a UPnP Internet Gateway Device Class in C++ with raw tcp/ip
    and udp calls.

    I want to now port that code to a high level interpreter that
    supplies
    SOAP methods.
    I need some help 'filling in the blanks' in this high level language.

    Here is the C++ method:

    //This code sends a message to the gateway to inquire about the
    external IP address. It builds up the soap envelope and message then
    posts //it and gets the response, parses it to extract the desired
    value.

    void IGD::getExterna lIPAddress(std: :string & NewExternalIPAd dress) {
    tcpclient poster;
    std::string htmlpost, xml;
    char buffer[2048];

    poster.connect( (char *) gatewayIPAddres s.c_str(), gatewayPort);

    xml += "<?xml version=\"1.0\" ?>\r\n";
    xml += "<s:Envelop e xmlns:s=\"http://schemas.xmlsoap .org/soap/
    envelope/\" s:encodingStyle =\"http://schemas.xmlsoap .org/soap/
    encoding/
    \">\r\n";
    xml += " <s:Body>\r\n" ;
    xml += " <u:GetExternalI PAddress xmlns:u=
    \"urn:schema s-upnp-
    org:service:WAN IPConnection:1\ "/>\r\n";
    xml += " </s:Body>\r\n";
    xml += "</s:Envelope>\r\n ";

    htmlpost += "POST /control?WANIPCo nnection HTTP/1.1\r\n";
    htmlpost += "HOST: ";
    htmlpost += gatewayIPAddres s;
    htmlpost += ":";
    htmlpost += itoa(gatewayPor t, buffer, 10);
    htmlpost += "\r\n";
    htmlpost += "CONTENT-LENGTH: ";
    htmlpost += itoa(xml.length (), buffer, 10);
    htmlpost += "\r\n";
    htmlpost += "CONTENT-TYPE: text/xml ; charset=\"utf-8\"\r\n";
    htmlpost += "SOAPACTION : \"urn:schema s-upnp-
    org:service:WAN IPConnection:1# GetExternalIPAd dress\"\r\n";
    htmlpost += "\r\n";
    htmlpost += xml;

    poster.send(htm lpost.c_str(), htmlpost.length ());
    int rc = poster.recv(buf fer, sizeof(buffer)) ;
    buffer[rc] = '\0';

    HtmlMsg serverResp(buff er);

    checkResponse(s erverResp);

    std::string xmlText = serverResp.getX ml();

    xmlObj xmlO(xmlText);
    std::cout << xmlO;
    xmlEntry e = xmlO.get("s:Env elope/s:Body/
    u:GetExternalIP AddressResponse/NewExternalIPAd dress");
    NewExternalIPAd dress = e.getValue();

    }

    The REALbasic interpreter provides a brief example of a soap call and
    I'm trying to use it, but I don't understand the parameters its
    asking
    for.
    Dim sm as SoapMethod
    Dim sr as SOAPResult
    // create the soap method and set the parameter(s)
    sm = New SoapMethod
    sm.parameter("U SZip") = "12345"

    // set soap method properties
    sm.methodNamesp ace = "http://www.webserviceX .NET"
    sm.action = "http://www.webserviceX .NET/GetInfoByZIP"
    sm.url = "http://www.webserviceX .NET/uszip.asmx"

    // execute the method
    sr = sm.invoke("GetI nfoByZIP")

    // display the Area_Code portion of the result
    MsgBox sr.result("Area _Code")

    The sm object has these attributes that can be set:
    action
    connection
    inputParams
    methodName
    methodNamespace
    namespaces
    paramTypes
    timeout
    url
    wsdl

Working...