Hey guys I'm new to the arduino and I'm trying to get the arduino to connect to a SOAP webservice, does anyone have sample code the shows how to call a webservice from arduino
Use the WebClient example of the Ethernet library as the base for your project. You probably won't find a full fledged, general use SOAP library for Arduino as an implementation of all the possibilities SOAP offers would be beyond the storage capabilities of a standard Arduino.
Usually Arduino sketches don't implement the whole protocol but just parse the relevant information out of the stream they are receiving. So in this example:
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<ns1:doubleAnIntegerResponse
xmlns:ns1="urn:MySoapServices"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xsi:type="xsd:int">246</return>
</ns1:doubleAnIntegerResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
the only interesting information is the number 246. This is normally done by looking for the string "<return", when found going on in the stream till the character '>' is matched. Now reading digits (only digits, the '<' character stops the reading) into a character array to be later converted to an integer by atoi or the like.
This limited parsing has to occur because the typical Arduino has a RAM size of 2kB, which would be burst by a DOM tree of this very simple example.
Thanks Pylon.
I was actually looking for arduino code that will call a webservice that will not retunr any values. For example the arduino will call the webservice and the service will send out an email.
This is handled almost the same way. Just create the XML you have to send to the web service manually and make it into client.println(F()) code lines with some lines in between where you client.print() the variable parts of your request. This is possible but it's a bit more manual programming work than you would have to invest on the PC platform with a programming environment doing most of the stuff for you (but using much more resources too).