user280: I am wanting to POST some data from Arduino to WebService (written in .NET), intending to save some temperature data to MS SQL Server.
My code in arduino is:
void PostarDados(String dados, String chamador) {
  if (client.connect("mysite.com.br",80)) {
    client.println(chamador);
    client.println(F("Host: mysite.com.br"));
    client.println(F("Content-Type: application/x-www-form-urlencoded"));
    client.print(F("Content-Length: "));
    client.println(dados.length());
    client.println();
    client.println(dados);
  }
  if (client.connected()) client.stop();
}

When sending to Serial instead of client, I am obtaining the following text:
POST /webservice.asmx/SetValoresTempUmidade HTTP/1.1
Host: mysite.com.br
Content-Type: application/x-www-form-urlencoded
Content-Length: 39

Chave=1&Temperatura=23.30&Umidade=42.20

I have enabled HTTP POST in web.config to make HTTP POST possible (I can successfully invoke webservice from browser):
  <location path="Webservice.asmx">
    <system.web>
      <webServices>
        <protocols>
          <add name="HttpGet"/>
          <add name="HttpPost"/>
        </protocols>
      </webServices>
    </system.web>
  </location>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

I have also set ScriptMethod to my webservice functions:
<WebMethod()> <ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)>
Public Sub SetValoresTempUmidade(Chave As Integer, ByVal Temperatura As Double, ByVal Umidade As Double)
    Dim ctx As New DataClassesDataContext
    Try
        Dim A As New TBL_DADO
        A.CHAVE_INICIO = Chave
        A.DATA = Now
        A.TEMPERATURA = Temperatura
        A.UMIDADE = Umidade
        ctx.TBL_DADOs.InsertOnSubmit(A)
        ctx.SubmitChanges()
    Catch ex As Exception
    End Try
End Sub

Finally, I am trying to get some response from server using the following code (not receiving anything):
while (client.connected()) {
  while (client.available()) {
   buffer[counter++] = client.read();
  }
}

Explained that, I have two questions:

What am I doing wrong?
How could I debug this?


user280: Using 
byte server[] = {XX, XX, XX, XX}; //IP
if (client.connect(server,80)) {

instead of
if (client.connect("mysite.com.br",80)) {

worked

280: <p>I am wanting to POST some data from Arduino to WebService (written in .NET), intending to save some temperature data to MS SQL Server.</p>

<p>My code in arduino is:</p>

<pre><code>void PostarDados(String dados, String chamador) {
  if (client.connect("mysite.com.br",80)) {
    client.println(chamador);
    client.println(F("Host: mysite.com.br"));
    client.println(F("Content-Type: application/x-www-form-urlencoded"));
    client.print(F("Content-Length: "));
    client.println(dados.length());
    client.println();
    client.println(dados);
  }
  if (client.connected()) client.stop();
}
</code></pre>

<p>When sending to Serial instead of client, I am obtaining the following text:</p>

<pre><code>POST /webservice.asmx/SetValoresTempUmidade HTTP/1.1
Host: mysite.com.br
Content-Type: application/x-www-form-urlencoded
Content-Length: 39

Chave=1&amp;Temperatura=23.30&amp;Umidade=42.20
</code></pre>

<p>I have enabled HTTP POST in web.config to make HTTP POST possible (I can successfully invoke webservice from browser):</p>

<pre><code>  &lt;location path="Webservice.asmx"&gt;
    &lt;system.web&gt;
      &lt;webServices&gt;
        &lt;protocols&gt;
          &lt;add name="HttpGet"/&gt;
          &lt;add name="HttpPost"/&gt;
        &lt;/protocols&gt;
      &lt;/webServices&gt;
    &lt;/system.web&gt;
  &lt;/location&gt;
  &lt;system.webServer&gt;
    &lt;httpProtocol&gt;
      &lt;customHeaders&gt;
        &lt;add name="Access-Control-Allow-Origin" value="*" /&gt;
        &lt;add name="Access-Control-Allow-Headers" value="Content-Type" /&gt;
      &lt;/customHeaders&gt;
    &lt;/httpProtocol&gt;
  &lt;/system.webServer&gt;
&lt;/configuration&gt;
</code></pre>

<p>I have also set <code>ScriptMethod</code> to my webservice functions:</p>

<pre><code>&lt;WebMethod()&gt; &lt;ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)&gt;
Public Sub SetValoresTempUmidade(Chave As Integer, ByVal Temperatura As Double, ByVal Umidade As Double)
    Dim ctx As New DataClassesDataContext
    Try
        Dim A As New TBL_DADO
        A.CHAVE_INICIO = Chave
        A.DATA = Now
        A.TEMPERATURA = Temperatura
        A.UMIDADE = Umidade
        ctx.TBL_DADOs.InsertOnSubmit(A)
        ctx.SubmitChanges()
    Catch ex As Exception
    End Try
End Sub
</code></pre>

<p>Finally, I am trying to get some response from server using the following code (not receiving anything):</p>

<pre><code>while (client.connected()) {
  while (client.available()) {
   buffer[counter++] = client.read();
  }
}
</code></pre>

<p>Explained that, I have two questions:</p>

<ol>
<li>What am I doing wrong?</li>
<li>How could I debug this?</li>
</ol>
 280: <p>Using </p>

<pre><code>byte server[] = {XX, XX, XX, XX}; //IP
if (client.connect(server,80)) {
</code></pre>

<p>instead of</p>

<pre><code>if (client.connect("mysite.com.br",80)) {
</code></pre>

<p>worked</p>
