SOAP サービスを呼び出すための完全な http 要求を作成する必要があります。SOAP リクエスト用のライブラリがないため、完全な HTTP パケットを書き込む必要があります。これが私が進めた方法です(私はarduinoボードをプログラミングしています):
String body = HttpRequestBody("33", "77%");
client.println("POST /dataserver HTTP/1.1");
client.println("Accept: text/xml, multipart/related");
client.println("Content-Type: text/xml; charset=utf-8");
client.println("SOAPAction: \"http://example.com/Functions/SendDataRequest\"");
client.println("User-Agent: Arduino WiFiShield");
client.println("Content-Length: "+body.length());
client.println("Host: arduino-data-server.appspot.com/dataserver");
client.println("Connection: Keep-Alive");
client.println();
client.println(body);
クライアントは、私の Web サービスへの接続を表します。これは HttpRequestBody 関数です:
String HttpRequestBody(String v1, String v2) {
Serial.println("Generating xml message...");
String res = "";
res += "<?xml version=\"1.0\"?>\n\r";
res +="<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"\n\r";
res +="<S:Body>\n\r";
res +="<ns2:sendData xmlsn:ns2=\"http://example.com\">\n\r";
res +="<arg0>"+v1+"</arg0>\n\r";
res +="<arg1>"+v2+"</arg1>\n\r";
res +="</ns2:sendData>\n\r";
res +="</S:Body>\n\r";
res +="</S:Envelope>\n\r";
Serial.println(res);
return res;
}
しかし、何かがうまくいかず、ウェブサーバーに接続できません。POST を GET に変更すると、Web サービス ログに接続が表示されるため、Web サーバーは動作し、再利用可能です。どうすれば修正できますか?