POST HTTP SENDER

Good. I really do this for the last option.
I have already tried several days to send a successful post petition to a web service.
I did it with the WCF client, create an application in c # that consumed it and everything works fine. Except with arduino. This is the shipping code, using arduino UNO and Ethernet shield2

 Serial.println("In SOPA");
    Serial.println("Connected to Server");
    client.println(F("POST /WS_PLANILLA.Service1.svc?wsdl HTTP/1.1"));
    client.println(F("Host:192.168.0.101:8312")); 
    client.println(F("Content-Type:text/xml; charset=utf-8"));
    client.println(F("Content-Length:215"));
    client.println();  
    client.print(F("<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"));
    client.print(F("<s:Header>"));

    client.print(F("<Action s:mustUnderstand=\"1\" xmlns=\"http://schemas.microsoft.com/ws/2005/05/addressing/none\">http://tempuri.org/IService1/ConsultaID</Action>"));
    client.print(F("</s:Header>"));
    client.print(F("<s:Body>"));
    client.print(F("<ConsultaID xmlns=\"http://tempuri.org/\"/>"));
    client.print(F("</s:Body>"));    
    client.print(F("</s:Envelope>"));      
    client.println();
    Serial.println("MAKE REQUEST DONE");[/sup]



and the response:


[sup]connecting...
192.168.0.103
In SOPA
Connected to Server
MAKE REQUEST DONE
HTTP/1.1 400 Bad Request
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Date: Fri, 23 Feb 2018 17:10:32 GMT
Content-Length: 0

HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 23 Feb 2018 17:10:32 GMT
Connection: close
Content-Length: 326

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Verb</h2>
<hr><p>HTTP Error 400. The request verb is invalid.</p>
</BODY></HTML>

disconnecting.

Any help is welcome

If I'm counting it right, your request body is longer than 215 bytes. It's more like 299 bytes.

the number of the request must be exact ??

and thanks for the answer

Here I have new information. I put the correct amount. That message I was sending was the one generated by the WCF client, change it by the message generated by SOAPUI, which is what I use in a C # application that I did to test this.

It is the following:

  Serial.println("In SOPA");
   Serial.println("Connected to Server");
   client.println(F("POST /WS_PLANILLA.Service1.svc?wsdl HTTP/1.1"));
   client.println(F("Host:192.168.0.101:8312")); 
   client.println(F("Content-Type:text/xml; charset=utf-8"));
   client.println(F("Content-Length:201"));
   client.println();  
   client.print(F("<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">"));
   client.print(F("<soapenv:Header/>"));

   client.print(F("<soapenv:Body>"));
   client.print(F("<tem:ConsultaID/>"));
   client.print(F("</soapenv:Body>"));
   client.print(F("</soapenv:Envelope>"));  
   client.println();
   Serial.println("MAKE REQUEST DONE");"



The problem is that now I do not receive any response, as if it was not sent.


"connecting...
192.168.0.103
In SOPA
Connected to Server
MAKE REQUEST DONE

disconnecting.

Giovax:
The problem is that now I do not receive any response, as if it was not sent.

Of course not, you don't have any code that would read or show the response.

Pieter

Sorry. The misunderstanding is because I have only posted the POST shipping code, here we show full

#include <SPI.h>
#include <Ethernet2.h>


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

byte server[] = { 192, 168, 0, 101 };

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

// 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) {
  ; // wait for serial port to connect. Needed for native USB port only
}

// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
  Serial.println("Failed to configure Ethernet using DHCP");
  // try to congifure using IP address instead of DHCP:
  Ethernet.begin(mac, ip);
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
Serial.println(Ethernet.localIP());

// if you get a connection, report back via serial:

if (client.connect(server, 8312)) {
      soapEnvelope();
} else {
  // if you didn't get a connection to the server:
  Serial.println("connection failed");
}
}



String soapEnvelope()
{
Serial.println("In SOPA");
  Serial.println("Connected to Server");
  client.println(F("POST /WS_PLANILLA.Service1.svc?wsdl HTTP/1.1"));
  client.println(F("Host:192.168.0.101:8312")); 
  client.println(F("Content-Type:text/xml; charset=utf-8"));
  client.println(F("Content-Length:204"));
  client.println();  
  client.print(F("<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">"));
  client.print(F("<soapenv:Header/>"));

  client.print(F("<soapenv:Body>"));
  client.print(F("<tem:ConsultaID/>"));
  client.print(F("</soapenv:Body>"));
  client.print(F("</soapenv:Envelope>"));  
  client.println();
  Serial.println("MAKE REQUEST DONE");

}

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);
}
}

There's no guarantee that there's data available to read when entering the loop.

Code:

---



```
void loopcolor=#000000[/color] {
while color=#000000[/color] {
// if there are incoming bytes available
// from the server, read them and print them:
if color=#000000[/color] {
char c = client.readcolor=#000000[/color];
Serial.printcolor=#000000[/color];
}
}
Serial.printlncolor=#000000[/color];
Serial.printlncolor=#000000[/color];
client.stopcolor=#000000[/color];

// do nothing forevermore:
 while color=#000000[/color];
}
```

|

You'll probably have to add a "Connection: close" header in your request.

I am very thankfull for your help.

I added the closing tag, in fact I had already done it in other tests, only that they were so many that I had forgotten.

But I still do not get an answer.

P.D: How do you make the color code?

#include <SPI.h>
#include <Ethernet2.h>


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

byte server[] = { 192, 168, 0, 101 };

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

// 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) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");
  Serial.println(Ethernet.localIP());
  
  // if you get a connection, report back via serial:
  
  if (client.connect(server, 8312)) {
        soapEnvelope();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}



String soapEnvelope()
{
  Serial.println("In SOPA");
    Serial.println("Connected to Server");
    client.println(F("POST /WS_PLANILLA.Service1.svc?wsdl HTTP/1.1"));
    client.println(F("Host:192.168.0.101:8312")); 
    client.println(F("Content-Type:text/xml; charset=utf-8"));
    client.println(F("Content-Length:204"));
    client.println(F("Connection: close"));
    client.println();  
    client.print(F("<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">"));
    client.print(F("<soapenv:Header/>"));

    client.print(F("<soapenv:Body>"));
    client.print(F("<tem:ConsultaID/>"));
    client.print(F("</soapenv:Body>"));
    client.print(F("</soapenv:Envelope>"));  

    client.println();
    Serial.println("MAKE REQUEST DONE");
  
}

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);
  }
}

Well I have published the same WS, which only has one method that returns "4" in the following address. In case you can help something.

http://52.36.59.165:8312/WS_PLANILLA.Service1.svc?wsdl

Did you try the code I posted?

Giovax:
P.D: How do you make the color code?

Arduino Forum Code Formatter.html

Yes.Iam Sorry, that I uploaded the wrong code.

#include <SPI.h>
#include <Ethernet2.h>


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

byte server[] = { 192, 168, 0, 101 };

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

// 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) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");
  Serial.println(Ethernet.localIP());
  
  // if you get a connection, report back via serial:
  
  if (client.connect(server, 8312)) {
        soapEnvelope();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}



String soapEnvelope()
{
  Serial.println("In SOPA");
    Serial.println("Connected to Server");
    client.println(F("POST /WS_PLANILLA.Service1.svc HTTP/1.1"));
    client.println(F("Host:192.168.0.101:8312")); 
    client.println(F("Content-Type:text/xml; charset=utf-8"));
    client.println(F("Content-Length:204"));
    client.println(F("Connection: close"));
    client.println();  
    client.print(F("<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">"));
    client.print(F("<soapenv:Header/>"));

    client.print(F("<soapenv:Body>"));
    client.print(F("<tem:ConsultaID/>"));
    client.print(F("</soapenv:Body>"));
    client.print(F("</soapenv:Envelope>"));  

    client.println();
    Serial.println("MAKE REQUEST DONE");
  
}

void loop() {
  while (client.connected()) {
    // if there are incoming bytes available
    // from the server, read them and print them:
    if (client.available()) {
      char c = client.read();
      Serial.print(c);
    }
  }
  Serial.println();
  Serial.println("disconnecting.");
  client.stop();

  // do nothing forevermore:
  while (true);
}

But i got the same result

Look, I do not understand this. If I change the connection tag I receive the following error:

CODE:

#include <SPI.h>
#include <Ethernet2.h>


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

byte server[] = { 192, 168, 0, 101 };

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

// 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) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");
  Serial.println(Ethernet.localIP());
  
  // if you get a connection, report back via serial:
  
  if (client.connect(server, 8312)) {
        soapEnvelope();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}



String soapEnvelope()
{
  Serial.println("In SOPA");
    Serial.println("Connected to Server");
    client.println(F("POST /WS_PLANILLA.Service1.svc HTTP/1.1"));
    client.println(F("Host:192.168.0.101:8312")); 
    client.println(F("Content-Type:text/xml; charset=utf-8"));
    client.println(F("Content-Length:204"));
    
    client.println("");
    client.print(F("<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">"));  
    client.print(F("<soapenv:Header/>"));    
    client.print(F("<soapenv:Body>"));
    client.print(F("<tem:ConsultaID/>"));
    client.print(F("</soapenv:Body>"));
    client.print(F("</soapenv:Envelope>")); 
    client.println(F("Connection: close"));
        client.println(""); 
    Serial.println("MAKE REQUEST DONE");
  
}

void loop() {
  while (client.connected()) {
    // if there are incoming bytes available
    // from the server, read them and print them:
    if (client.available()) {
      char c = client.read();
      Serial.print(c);
    }
  }
  Serial.println();
  Serial.println("disconnecting.");
  client.stop();

  // do nothing forevermore:
  while (true);
}

ANSWER:

connecting...
192.168.0.103
In SOPA
Connected to Server
MAKE REQUEST DONE
HTTP/1.1 400 Bad Request
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Date: Mon, 26 Feb 2018 15:02:23 GMT
Content-Length: 0

And that's fine, the request is wrong, but if I put the connection tag where it should be, I simply do not receive anything.

CODE

#include <SPI.h>
#include <Ethernet2.h>


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

byte server[] = { 192, 168, 0, 101 };

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

// 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) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");
  Serial.println(Ethernet.localIP());
  
  // if you get a connection, report back via serial:
  
  if (client.connect(server, 8312)) {
        soapEnvelope();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}



String soapEnvelope()
{
  Serial.println("In SOPA");
    Serial.println("Connected to Server");
    client.println(F("POST /WS_PLANILLA.Service1.svc HTTP/1.1"));
    client.println(F("Host:192.168.0.101:8312")); 
    client.println(F("Content-Type:text/xml; charset=utf-8"));
    client.println(F("Content-Length:204"));
    client.println(F("Connection: close"));
    client.println("");
    client.print(F("<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">"));  
    client.print(F("<soapenv:Header/>"));    
    client.print(F("<soapenv:Body>"));
    client.print(F("<tem:ConsultaID/>"));
    client.print(F("</soapenv:Body>"));
    client.print(F("</soapenv:Envelope>")); 
        client.println(""); 
    Serial.println("MAKE REQUEST DONE");
  
}

void loop() {
  while (client.connected()) {
    // if there are incoming bytes available
    // from the server, read them and print them:
    if (client.available()) {
      char c = client.read();
      Serial.print(c);
    }
  }
  Serial.println();
  Serial.println("disconnecting.");
  client.stop();

  // do nothing forevermore:
  while (true);
}

ANSWER:

connecting...
192.168.0.103
In SOPA
Connected to Server
MAKE REQUEST DONE

That's very strange ... I'm afraid I can't help you. Did you try sending the request using cURL or netcat?

To test if the Ws works ???. I already tested it with WCF client and a small application in c # I did.

But doing more tests I have another interesting example. look at this code

#include <SPI.h>
#include <Ethernet2.h>


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

byte server[] = { 192, 168, 0, 101 };

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

// 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) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");
  Serial.println(Ethernet.localIP());
  
  // if you get a connection, report back via serial:
  
  if (client.connect(server, 8312)) {
        soapEnvelope();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}



String soapEnvelope()
{
  Serial.println("In SOPA");
    Serial.println("Connected to Server");
    client.println(F("POST /WS_PLANILLA.Service1.svc HTTP/1.1"));
    client.println(F("SOAPAction: http://tempuri.org/IService1/ConsultaID"));     
    client.println(F("Content-Type:text/xml; charset=utf-8"));
    client.println(F("Accept: text/xml"));
    client.println(F("Host:192.168.0.101:8312"));
    client.println(F("Content-Length: 212"));
    client.println(F("Expect: 100-continue"));
    client.println(F("Connection: close"));
 
    client.print(F("<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">"));  
    client.print(F("<soapenv:Header/>"));    
    client.print(F("<soapenv:Body>"));
    client.print(F("<tem:ConsultaID/>"));
    client.print(F("</soapenv:Body>"));
    client.print(F("</soapenv:Envelope>")); 
    client.println(""); 
    Serial.println("MAKE REQUEST DONE");
  
}

void loop() {
  while (client.connected()) {
    // if there are incoming bytes available
    // from the server, read them and print them:
    if (client.available()) {
      char c = client.read();
      Serial.print(c);
    }
  }
  Serial.println();
  Serial.println("disconnecting.");
  client.stop();

  // do nothing forevermore:
  while (true);
}

missing the line break after the header. And I get this error:

connecting...
192.168.0.103
In SOPA
Connected to Server
MAKE REQUEST DONE
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Mon, 26 Feb 2018 17:18:51 GMT
Connection: close
Content-Length: 339

Bad Request

Bad Request - Invalid Header


HTTP Error 400. The request has an invalid header name.

disconnecting.

But if I put it in, again I do not get anything

connecting...
192.168.0.103
In SOPA
Connected to Server
MAKE REQUEST DONE

:o :o :o :o

Thanks for all the help

more data, look what happens if I remove the label
client.println(F("Content-Length: 212")); :

connecting...
192.168.0.103
In SOPA
Connected to Server
MAKE REQUEST DONE
HTTP/1.1 411 Length Required
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Mon, 26 Feb 2018 17:43:38 GMT
Connection: close
Content-Length: 344

Length Required

Length Required


HTTP Error 411. The request must be chunked or have a content length.

disconnecting.

The problem is obvious. I just do not understand why if you put the label it just does not respond

More data.

Now add a new tag and I get the following. At least it's better than nothing.

String soapEnvelope()
{
  Serial.println("In SOPA");
    Serial.println("Connected to Server");
    client.println(F("POST /WS_PLANILLA.Service1.svc?wsdl HTTP/1.1"));
    client.println(F("SOAPAction: http://tempuri.org/IService1/ConsultaID"));     
    client.println(F("Content-Type:text/xml; charset=utf-8"));
    client.println(F("Accept: text/xml"));
    client.println(F("Host:192.168.0.101:8312"));
    client.println(F("Content-Length: 212"));
    client.println(F("Expect: 100-continue"));
    client.println(F("Connection: Keep-Alive"));
    client.println();
    client.println("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
    client.print(F("<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">"));  
    client.print(F("<soapenv:Header/>"));    
    client.print(F("<soapenv:Body>"));
    client.print(F("<tem:ConsultaID/>"));
    client.print(F("</soapenv:Body>"));
    client.print(F("</soapenv:Envelope>")); 
    client.println(""); 
    Serial.println("MAKE REQUEST DONE");
  
}

Response:

connecting...
192.168.0.103
In SOPA
Connected to Server
MAKE REQUEST DONE
1
HTTP/1.1 400 Bad Request
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Date: Mon, 26 Feb 2018 18:48:48 GMT
Content-Length: 0

HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Mon, 26 Feb 2018 18:48:48 GMT
Connection: close
Content-Length: 326

Bad Request

Bad Request - Invalid Verb


HTTP Error 400. The request verb is invalid.

disconnecting.

I'm here again. Someday I'll have to do it :-D.
Okay. Now I made a new application in C #, but this time I consumed the WS through a POST request.

Now do it and try to place the same values ​​in the arduino. Now I have an answer "100-continue", looking I realized that it is an affirmative answer on the part of the client that must be answered to be able to return the message, the problem is that it does not happen all the time -.-. I also publish the code here.\

#include <SPI.h>
#include <Ethernet2.h>


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

byte server[] = { 192, 168, 0, 101 };

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

// 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) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");
  Serial.println(Ethernet.localIP());
  
  // if you get a connection, report back via serial:
  
  if (client.connect(server, 8312)) {
        soapEnvelope();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}



String soapEnvelope()
{
  Serial.println("In SOPA");
    Serial.println("Connected to Server");
    client.println("POST /WS_PLANILLA.Service1.svc HTTP/1.1");
    client.println("Content-Type: text/xml; charset=utf-8");
    client.println("SOAPAction: http://tempuri.org/IService1/ConsultaID");      
    client.println("Host: 192.168.0.101:8312");
    client.println("Content-Length: 244");
    client.println("Expect: 100-continue"); 
    client.println("Connection: close");
    client.println();    
    client.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    client.println("<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">");  
    client.println("<soapenv:Header/>");    
    client.println("<soapenv:Body><tem:ConsultaID/>");
    client.println("</soapenv:Body>");
    client.println("</soapenv:Envelope>");   
  client.println();
    Serial.println("MAKE REQUEST DONE");
  
}

void loop() {
  char c;
  while (client.connected()) {
    if (client.available()) {
      c = client.read();
      Serial.print(c);
    }
  }
  Serial.println();
  Serial.println("disconnecting.");
  Serial.println(c);
  
  client.stop();

  // do nothing forevermore:
  while (true);
}

I have obtained, always get the answer "100 Continue", and no longer randomly, changing the way I made the request, but if I sent the answer 100 gives me that bad response. Any idea >> ???? I provide the current answer and the code.

REsponse:

connecting...
192.168.0.103
In SOPA
Connected to Server
MAKE REQUEST DONE
HTTP/1.1 100 Continue

disconnecting.

CODE:

#include <SPI.h>
#include <Ethernet2.h>


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

byte server[] = { 192, 168, 0, 101 };

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

// 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) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");
  Serial.println(Ethernet.localIP());
  
  // if you get a connection, report back via serial:
  
  if (client.connect(server, 8312)) {
        soapEnvelope();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}



String soapEnvelope()
{

    char outBuf[244];
    
  Serial.println("In SOPA");
    Serial.println("Connected to Server");
    sprintf(outBuf,"POST /WS_PLANILLA.Service1.svc HTTP/1.1");
    client.println(outBuf);
    sprintf(outBuf,"Content-Type: text/xml; charset=utf-8");
    client.println(outBuf);
    sprintf(outBuf,"SOAPAction: http://tempuri.org/IService1/ConsultaID");
    client.println(outBuf);
    sprintf(outBuf,"Host: 192.168.0.101:8312");
    client.println(outBuf);     
    sprintf(outBuf,"Content-Length: 244");
    client.println(outBuf);
    sprintf(outBuf,"Expect: 100-continue");
    client.println(outBuf);
    sprintf(outBuf,"Connection: keep-alive");
    client.println(outBuf);
    client.println(); 
    sprintf(outBuf,"<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/""><soapenv:Header/><soapenv:Body><tem:ConsultaID/></soapenv:Body></soapenv:Envelope>");
    client.println(outBuf);   
  client.println();
    Serial.println("MAKE REQUEST DONE");
  
}

void loop() {
  char c;
  while (client.connected()) {
    if (client.available()) {
      c = client.read();
      Serial.print(c);
    }
   
  }
  Serial.println();
  Serial.println("disconnecting.");
  Serial.println(c);
  
  client.stop();

  // do nothing forevermore:
  while (true);
}