Hi there...
I really new on both arduino and webservices, so basilly I followed a simple example on the net to create the web service and how to publish it using IIS here is the code:
ogactivation
Test
The test form is only available for requests from the local machine.
SOAP 1.1
The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.
POST /WebServiceSQL/WebServiceSQL.asmx HTTP/1.1
Host: toponet.zapto.org
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://toponet.zapto.org/logactivation"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<logactivation xmlns="http://toponet.zapto.org">
<pinnumber>int</pinnumber>
</logactivation>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<logactivationResponse xmlns="http://toponet.zapto.org">
<logactivationResult>dateTime</logactivationResult>
</logactivationResponse>
</soap:Body>
</soap:Envelope>
so as you can see the webservice name is WebServiceSQL and has an action named logactivation wich receive an integer and reply the date and time.
Here is the code that I wrote on the Arduino
/*
Web client
*/
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address for your controller below.
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
IPAddress server(192,168,2,90); // numeric IP (no DNS)
//char server[] = "http://toponet.zapto.org:90"; // using DNS
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192,168,2,105);
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
;
}
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, ip);
}
delay(1000);
Serial.println("connecting...");
if (client.connect(server, 80)) {
Serial.println(F("connected"));
// Make a HTTP request:
/*
POST /WebServiceSQL/WebServiceSQL.asmx HTTP/1.1
Host: toponet.zapto.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<logactivation xmlns="http://toponet.zapto.org">
<pinnumber>int</pinnumber>
</logactivation>
</soap12:Body>
</soap12:Envelope>
*/
client.println(F("POST /WebServiceSQL/WebServiceSQL.asmx HTTP/1.1"));
client.println(F("Host: \192.168.2.90"));
client.println(F("Content-Type: text/xml; charset=utf-8"));
client.println(F("Content-Length: \100"));
client.println(F("SOAPAction: \"http://toponet.zapto.org/logactivation\""));
client.println(F("\r\n"));
client.println(F("<?xml version=\"1.0\" encoding=\"utf-8\"?>"));
client.println(F("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"));
client.println(F("<soap:Body>"));
client.println(F("<logactivation xmlns=http://toponet.zapto.org>"));
client.println(F("<pinnumber>\"3\"</pinnumber>"));
client.println(F("</logactivation>"));
client.println(F("</soap:Body>"));
client.println(F("</soap:Envelope>"));
client.println(F("Connection: close"));
client.println(F("\r\n"));
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
while(true);
}
}
but I received this on the serial monitor:
connecting...
connected
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Tue, 22 Apr 2014 02:44:54 GMT
Connection: close
Content-Length: 311
Bad Request
HTTP Error 400. The request is badly formed.
disconnecting.
I need some EXAMPLE on how to generate the arduino code to make this work... many thanks in advance.