A Question about using SOAP in REALbasic

S

SpreadTooThin

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::getExternalIPAddress(std::string & NewExternalIPAddress) {
tcpclient poster;
std::string htmlpost, xml;
char buffer[2048];

poster.connect((char *) gatewayIPAddress.c_str(), gatewayPort);

xml += "<?xml version=\"1.0\"?>\r\n";
xml += "<s:Envelope 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:GetExternalIPAddress xmlns:u=
\"urn:schemas-upnp-
org:service:WANIPConnection:1\"/>\r\n";
xml += " </s:Body>\r\n";
xml += "</s:Envelope>\r\n";

htmlpost += "POST /control?WANIPConnection HTTP/1.1\r\n";
htmlpost += "HOST: ";
htmlpost += gatewayIPAddress;
htmlpost += ":";
htmlpost += itoa(gatewayPort, 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:schemas-upnp-
org:service:WANIPConnection:1#GetExternalIPAddress\"\r\n";
htmlpost += "\r\n";
htmlpost += xml;

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

HtmlMsg serverResp(buffer);

checkResponse(serverResp);

std::string xmlText = serverResp.getXml();

xmlObj xmlO(xmlText);
std::cout << xmlO;
xmlEntry e = xmlO.get("s:Envelope/s:Body/
u:GetExternalIPAddressResponse/NewExternalIPAddress");
NewExternalIPAddress = 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("USZip") = "12345"

// set soap method properties
sm.methodNamespace = "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("GetInfoByZIP")

// 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top