Indy https post returns HTTP/1.0 500 Error - help

Hi,

I am using XE7, Win8.1

I have a https site with a webservice and I am trying to use Indy HTTP to post a request without success. I always get "HTTP/1.0 500 Error"

I have tested with SOAPUI. I can to do  a request post and I get a correct response. Here is the post with SOAPUI.
Request:
{code}
POST https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
Content-Length: 4463
Host: wsp.hom.orizonbrasil.com.br:6214
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.ans.gov.br/padroes/tiss/schemas" xmlns:xd="http://www.w3.org/2000/09/xmldsig#">
   <soapenv:Header/>
   <soapenv:Body>
      <sch:solicitacaoProcedimentoWS>
         <sch:cabecalho>
            <sch:identificacaoTransacao>
               <sch:tipoTransacao>SOLICITACAO_PROCEDIMENTOS</sch:tipoTransacao>
               <sch:sequencialTransacao>k1</sch:sequencialTransacao>
               <sch:dataRegistroTransacao>2015-01-30</sch:dataRegistroTransacao>
               <sch:horaRegistroTransacao>16:55:00</sch:horaRegistroTransacao>
......
......
{code}

Response with SOAPUI:
{code}
HTTP/1.1 200 OK
X-Backside-Transport: OK OK
Connection: Keep-Alive
Content-Encoding: gzip
Transfer-Encoding: chunked
Content-Type: text/xml
Date: Tue, 10 Feb 2015 12:56:43 GMT
Server: DistribuidorV3-Orizon/4.6.2
X-Client-IP: 179.236.254.241

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.ans.gov.br/padroes/tiss/schemas" xmlns:xd="http://www.w3.org/2000/09/xmldsig#">
   <soapenv:Header/>
   <soapenv:Body>  <sch:autorizacaoProcedimentoWS>
    <sch:cabecalho>
      <sch:identificacaoTransacao>
        <sch:tipoTransacao>RESPOSTA_SOLICITACAO</sch:tipoTransacao>
        <sch:sequencialTransacao>k1</sch:sequencialTransacao>
        <sch:dataRegistroTransacao>2015-01-30</sch:dataRegistroTransacao>
        <sch:horaRegistroTransacao>16:55:00</sch:horaRegistroTransacao>
      </sch:identificacaoTransacao>
      <sch:falhaNegocio>5015</sch:falhaNegocio>
      <sch:origem>
        <sch:identificacaoPrestador>
          <sch:codigoPrestadorNaOperadora>4529</sch:codigoPrestadorNaOperadora>
        </sch:identificacaoPrestador>

......
.......
{code}



Using Indy, I am trying to do the same request post but I get always HTTP/1.0 500 Error

Here is my code:
{code}
procedure TForm5.Button3Click(Sender: TObject);
var S: TStringList;
   M: TStream;
  SSL1 : TIdSSLIOHandlerSocketOpenSSL;
begin
 SSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
 SSL1.SSLOptions.Method := sslvSSLv23;
 S := TStringList.Create;
 M := TMemoryStream.Create;
 try
   
   // here is the content starting at  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
   //xmlns:sch="http://www.ans.gov.br/padroes/tiss/schemas" xmlns:xd="http://www.w3.org/2000/09/xmldsig#">
   S.Text:=Memo1.Text; 

   IdHTTP1.IOHandler := SSL1;
   IdHTTP1.Request.ContentType := 'text/xml;charset=UTF-8';

   IdHTTP1.Post('https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento', S, M);

   MemoResp.Lines.Add(Format('Response Code: %d', [IdHTTP1.ResponseCode]));
   MemoResp.Lines.Add(Format('Response Text: %s', [IdHTTP1.ResponseText]));

   M.Position := 0;
   S.LoadFromStream(M);
   MemoResp.Lines.AddStrings(S);
 finally
   SSl1.Free;
   S.Free;
   M.Free;
 end;
end;
{code}

Please, some help will be appreciated.

Thanks in Advance,

Luiz
0
Luiz
2/10/2015 1:30:33 PM
embarcadero.delphi.winsock 1874 articles. 2 followers. Follow

11 Replies
3190 Views

Similar Articles

[PageSpeed] 56

Mr Remy,

Very thanks for your help.

I have tried your two suggestions, but the result is the same. I still have the same  "HTTP/1.0 500 Error"

The site has a webservice  in "https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento" and  I have no certicate installed in windows. 

Also, I didn´t installed certificate in SOAPUI and it works well.

The site administrator said me that certificate is not required.

First, I was trying to consume the webservice with HTTPRIO-SOAP using WinInet(default install drom XE7) and I have no success. It shows a message saying a certificatte is required to authetication of the client. Although the certificate is not required, I get always this message.

So,  trying to solve the problem I compiled SOAP units to work using Indy instead WinInet but when I try consume the webservice I get  a message  "HTTP/1.0 500 Internal Server Error".

I am now trying post directly with IdHttp and I get the error: HTTP/1.0 500 Error

With Indy or WinInet I am unable to get a correct response. 

With SOPAUI, all is ok.

Can you help me to solve it?

Best Regards,

Luiz




> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> Luiz wrote:
> 
> > I have a https site with a webservice and I am trying to use Indy HTTP
> > to post a request without success. I always get "HTTP/1.0 500 Error"
> 
> That usually means you are posting bad data to the server, causing it to 
> crash or otherwise mismanage the request.  500 is typically used for server-side 
> runtime errors.
> 
> > I have tested with SOAPUI. I can to do  a request post and I get a
> > correct response. Here is the post with SOAPUI.
> <snip>
> > Using Indy, I am trying to do the same request post but I get always
> > HTTP/1.0 500 Error
> 
> That is because you are posting the SOAP data using a TStringList.  TIdHTTP 
> encodes TStrings data in a manner appropriate for an "application/x-www-form-urlencoded" 
> formatted request (ie, a webform submission), which your server is not expecting, 
> and is going to break you XML.  You need to use a TStream instead, so TIdHTTP 
> will post the XML as-is, eg:
> 
> {code}
> procedure TForm5.Button3Click(Sender: TObject);
> var
>   Req, Resp: TStream;
>   SL: TStringList;
>   SSL1 : TIdSSLIOHandlerSocketOpenSSL;
> begin
>   Resp := TMemoryStream.Create;
>   try
>     Req := TMemoryStream.Create;
>     try
>       WriteStringToStream(Req, Memo1.Text, IndyTextEncoding_UTF8);
>       Req.Position := 0;
> 
>       SSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
>       try
>         SSL1.SSLOptions.Method := sslvSSLv23;
>         IdHTTP1.IOHandler := SSL1;
> 
>         IdHTTP1.Request.ContentType := 'text/xml';
>         IdHTTP1.Request.Charset := 'UTF-8';
>         IdHTTP1.Post('https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento', 
> Req, Resp);
>       finally
>         SSl1.Free;
>       end;
>     finally
>       Req.Free;
>     end;
> 
>     MemoResp.Lines.Add(Format('Response Code: %d', [IdHTTP1.ResponseCode]));
>     MemoResp.Lines.Add(Format('Response Text: %s', [IdHTTP1.ResponseText]));
> 
>     SL := TStirngList.Create;
>     try
>       Resp.Position := 0;
>       SL.LoadFromStream(Resp);
>       MemoResp.Lines.AddStrings(SL);
>     finally
>       SL.Free;
>     end;
>   finally
>     Resp.Free;
>   end;
> end;
> {code}
> 
> 
> Alternatively:
> 
> {code}
> procedure TForm5.Button3Click(Sender: TObject);
> var
>   Req: TStream;
>   SL: TStringList;
>   S: String;
>   SSL1 : TIdSSLIOHandlerSocketOpenSSL;
> begin
>   Req := TStringStream.Create(Memo1.Text, TEncoding.UTF8);
>   try
>     SSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
>     try
>       SSL1.SSLOptions.Method := sslvSSLv23;
>       IdHTTP1.IOHandler := SSL1;
> 
>       IdHTTP1.Request.ContentType := 'text/xml';
>       IdHTTP1.Request.Charset := 'UTF-8';
> 
>       S := IdHTTP1.Post('https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento', 
> Req);
>     finally
>       SSl1.Free;
>     end;
>   finally
>     Req.Free;
>   end;
> 
>   MemoResp.Lines.Add(Format('Response Code: %d', [IdHTTP1.ResponseCode]));
>   MemoResp.Lines.Add(Format('Response Text: %s', [IdHTTP1.ResponseText]));
> 
>   SL := TStringList.Create;
>   try
>     SL.Text := S;
>     MemoResp.Lines.AddStrings(SL);
>   finally
>     SL.Free;
>   end;
> end;
> {code}
> 
> -- 
> Remy Lebeau (TeamB)

Edited by: Luiz Oliveira on Feb 10, 2015 2:02 PM
-1
Luiz
2/10/2015 1:01:01 AM
Luiz wrote:

> I have a https site with a webservice and I am trying to use Indy HTTP
> to post a request without success. I always get "HTTP/1.0 500 Error"

That usually means you are posting bad data to the server, causing it to 
crash or otherwise mismanage the request.  500 is typically used for server-side 
runtime errors.

> I have tested with SOAPUI. I can to do  a request post and I get a
> correct response. Here is the post with SOAPUI.
<snip>
> Using Indy, I am trying to do the same request post but I get always
> HTTP/1.0 500 Error

That is because you are posting the SOAP data using a TStringList.  TIdHTTP 
encodes TStrings data in a manner appropriate for an "application/x-www-form-urlencoded" 
formatted request (ie, a webform submission), which your server is not expecting, 
and is going to break you XML.  You need to use a TStream instead, so TIdHTTP 
will post the XML as-is, eg:

{code}
procedure TForm5.Button3Click(Sender: TObject);
var
  Req, Resp: TStream;
  SL: TStringList;
  SSL1 : TIdSSLIOHandlerSocketOpenSSL;
begin
  Resp := TMemoryStream.Create;
  try
    Req := TMemoryStream.Create;
    try
      WriteStringToStream(Req, Memo1.Text, IndyTextEncoding_UTF8);
      Req.Position := 0;

      SSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
      try
        SSL1.SSLOptions.Method := sslvSSLv23;
        IdHTTP1.IOHandler := SSL1;

        IdHTTP1.Request.ContentType := 'text/xml';
        IdHTTP1.Request.Charset := 'UTF-8';
        IdHTTP1.Post('https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento', 
Req, Resp);
      finally
        SSl1.Free;
      end;
    finally
      Req.Free;
    end;

    MemoResp.Lines.Add(Format('Response Code: %d', [IdHTTP1.ResponseCode]));
    MemoResp.Lines.Add(Format('Response Text: %s', [IdHTTP1.ResponseText]));

    SL := TStirngList.Create;
    try
      Resp.Position := 0;
      SL.LoadFromStream(Resp);
      MemoResp.Lines.AddStrings(SL);
    finally
      SL.Free;
    end;
  finally
    Resp.Free;
  end;
end;
{code}


Alternatively:

{code}
procedure TForm5.Button3Click(Sender: TObject);
var
  Req: TStream;
  SL: TStringList;
  S: String;
  SSL1 : TIdSSLIOHandlerSocketOpenSSL;
begin
  Req := TStringStream.Create(Memo1.Text, TEncoding.UTF8);
  try
    SSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
    try
      SSL1.SSLOptions.Method := sslvSSLv23;
      IdHTTP1.IOHandler := SSL1;

      IdHTTP1.Request.ContentType := 'text/xml';
      IdHTTP1.Request.Charset := 'UTF-8';

      S := IdHTTP1.Post('https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento', 
Req);
    finally
      SSl1.Free;
    end;
  finally
    Req.Free;
  end;

  MemoResp.Lines.Add(Format('Response Code: %d', [IdHTTP1.ResponseCode]));
  MemoResp.Lines.Add(Format('Response Text: %s', [IdHTTP1.ResponseText]));

  SL := TStringList.Create;
  try
    SL.Text := S;
    MemoResp.Lines.AddStrings(SL);
  finally
    SL.Free;
  end;
end;
{code}

-- 
Remy Lebeau (TeamB)
1
Remy
2/10/2015 6:53:34 PM
Mr Remy,

Very thanks for your help.

I have tried your two suggestions, but the result is the same. I still have the same  "HTTP/1.0 500 Error"

The site has a webservice  in "https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento" and  I have no certicate installed in windows. 

Also, I didn´t installed certificate in SOAPUI and it works well.

The site administrator said me that certificate is not required.

With Indy I am unable to get a correct response.

Can you help me to solve it?

Best Regards,

Luiz




> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> Luiz wrote:
> 
> > I have a https site with a webservice and I am trying to use Indy HTTP
> > to post a request without success. I always get "HTTP/1.0 500 Error"
> 
> That usually means you are posting bad data to the server, causing it to 
> crash or otherwise mismanage the request.  500 is typically used for server-side 
> runtime errors.
> 
> > I have tested with SOAPUI. I can to do  a request post and I get a
> > correct response. Here is the post with SOAPUI.
> <snip>
> > Using Indy, I am trying to do the same request post but I get always
> > HTTP/1.0 500 Error
> 
> That is because you are posting the SOAP data using a TStringList.  TIdHTTP 
> encodes TStrings data in a manner appropriate for an "application/x-www-form-urlencoded" 
> formatted request (ie, a webform submission), which your server is not expecting, 
> and is going to break you XML.  You need to use a TStream instead, so TIdHTTP 
> will post the XML as-is, eg:
> 
> {code}
> procedure TForm5.Button3Click(Sender: TObject);
> var
>   Req, Resp: TStream;
>   SL: TStringList;
>   SSL1 : TIdSSLIOHandlerSocketOpenSSL;
> begin
>   Resp := TMemoryStream.Create;
>   try
>     Req := TMemoryStream.Create;
>     try
>       WriteStringToStream(Req, Memo1.Text, IndyTextEncoding_UTF8);
>       Req.Position := 0;
> 
>       SSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
>       try
>         SSL1.SSLOptions.Method := sslvSSLv23;
>         IdHTTP1.IOHandler := SSL1;
> 
>         IdHTTP1.Request.ContentType := 'text/xml';
>         IdHTTP1.Request.Charset := 'UTF-8';
>         IdHTTP1.Post('https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento', 
> Req, Resp);
>       finally
>         SSl1.Free;
>       end;
>     finally
>       Req.Free;
>     end;
> 
>     MemoResp.Lines.Add(Format('Response Code: %d', [IdHTTP1.ResponseCode]));
>     MemoResp.Lines.Add(Format('Response Text: %s', [IdHTTP1.ResponseText]));
> 
>     SL := TStirngList.Create;
>     try
>       Resp.Position := 0;
>       SL.LoadFromStream(Resp);
>       MemoResp.Lines.AddStrings(SL);
>     finally
>       SL.Free;
>     end;
>   finally
>     Resp.Free;
>   end;
> end;
> {code}
> 
> 
> Alternatively:
> 
> {code}
> procedure TForm5.Button3Click(Sender: TObject);
> var
>   Req: TStream;
>   SL: TStringList;
>   S: String;
>   SSL1 : TIdSSLIOHandlerSocketOpenSSL;
> begin
>   Req := TStringStream.Create(Memo1.Text, TEncoding.UTF8);
>   try
>     SSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
>     try
>       SSL1.SSLOptions.Method := sslvSSLv23;
>       IdHTTP1.IOHandler := SSL1;
> 
>       IdHTTP1.Request.ContentType := 'text/xml';
>       IdHTTP1.Request.Charset := 'UTF-8';
> 
>       S := IdHTTP1.Post('https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento', 
> Req);
>     finally
>       SSl1.Free;
>     end;
>   finally
>     Req.Free;
>   end;
> 
>   MemoResp.Lines.Add(Format('Response Code: %d', [IdHTTP1.ResponseCode]));
>   MemoResp.Lines.Add(Format('Response Text: %s', [IdHTTP1.ResponseText]));
> 
>   SL := TStringList.Create;
>   try
>     SL.Text := S;
>     MemoResp.Lines.AddStrings(SL);
>   finally
>     SL.Free;
>   end;
> end;
> {code}
> 
> -- 
> Remy Lebeau (TeamB)
-1
Luiz
2/10/2015 9:40:59 PM
Luiz wrote:

> I have tried your two suggestions, but the result is the same. I
> still have the same  "HTTP/1.0 500 Error"

Then either your SOAP XML is malformed, or you are not posting everything 
that the webservice is expecting (for instance, are you setting the SOAP-related 
HTTP headers anywhere in your code? You did not show that).  You could use 
a debugging proxy, such as Fiddler, to compare the requests of SOAPUI and 
TIdHTTP to see what is different between them, and then update your TIdHTTP 
code accordingly.

-- 
Remy Lebeau (TeamB)
-1
Remy
2/10/2015 10:03:23 PM
Luiz wrote:

> I have tried your two suggestions, but the result is the same. I
> still have the same  "HTTP/1.0 500 Error"

Then either your SOAP XML is malformed, or you are not posting everything 
that the webservice is expecting (for instance, are you setting the SOAP-related 
HTTP headers anywhere in your code? You did not show that).  You could use 
a debugging proxy, such as Fiddler, to compare the requests of SOAPUI and 
TIdHTTP to see what is different between them, otherwise have the site admin
debug the webservice and find out why it is returning 500, and then update your
TIdHTTP  code accordingly.

-- 
Remy Lebeau (TeamB)
0
Remy
2/10/2015 10:05:05 PM
Mr Reny,

These are the Headers showing in SOAP. I copied them to IdHttp but the error is the same.

{code}
POST https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
Content-Length: 4463
Host: wsp.hom.orizonbrasil.com.br:6214
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.ans.gov.br/padroes/tiss/schemas" xmlns:xd="http://www.w3.org/2000/09/xmldsig#">
   <soapenv:Header/>
   <soapenv:Body>
      <sch:solicitacaoProcedimentoWS>
         <sch:cabecalho>
            <sch:identificacaoTransacao>
               <sch:tipoTransacao>SOLICITACAO_PROCEDIMENTOS</sch:tipoTransacao>
               <sch:sequencialTransacao>k1</sch:sequencialTransacao>
               <sch:dataRegistroTransacao>2015-01-30</sch:dataRegistroTransacao>
               <sch:horaRegistroTransacao>16:55:00</sch:horaRegistroTransacao>
            </sch:identificacaoTransacao>
             <sch:origem>

{code}

Here is my delphi code:

{code}
procedure TForm5.Button3Click(Sender: TObject);
var
  Req: TStream;
  SL: TStringList;
  S: String;
  SSL1 : TIdSSLIOHandlerSocketOpenSSL;
begin
  Req := TStringStream.Create(Memo1.Text, TEncoding.UTF8);
  try
    SSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
    try
      SSL1.SSLOptions.Method := sslvSSLv23;
      IdHTTP1.IOHandler := SSL1;
      IdHTTP1.Request.ContentType := 'text/xml';
      IdHTTP1.Request.Charset := 'UTF-8';
      IdHTTP1.Request.AcceptEncoding:='gzip,deflate';
      IdHTTP1.Request.Connection:='Keep-Alive';
      IdHTTP1.Request.UserAgent:='Apache-HttpClient/4.1.1 (java 1.5)';
     IdHTTP1.Request.RawHeaders.Add('SOAPAction: ""');

      S := IdHTTP1.Post('https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento',
Req);
    finally
      SSl1.Free;
    end;
  finally
    Req.Free;
  end;

  MemoResp.Lines.Add(Format('Response Code: %d', [IdHTTP1.ResponseCode]));
  MemoResp.Lines.Add(Format('Response Text: %s', [IdHTTP1.ResponseText]));

  SL := TStringList.Create;
  try
    SL.Text := S;
    MemoResp.Lines.AddStrings(SL);
  finally
    SL.Free;
  end;
end;
{code}


> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> Luiz wrote:
> 
> > I have tried your two suggestions, but the result is the same. I
> > still have the same  "HTTP/1.0 500 Error"
> 
> Then either your SOAP XML is malformed, or you are not posting everything 
> that the webservice is expecting (for instance, are you setting the SOAP-related 
> HTTP headers anywhere in your code? You did not show that).  You could use 
> a debugging proxy, such as Fiddler, to compare the requests of SOAPUI and 
> TIdHTTP to see what is different between them, otherwise have the site admin
> debug the webservice and find out why it is returning 500, and then update your
> TIdHTTP  code accordingly.
> 
> -- 
> Remy Lebeau (TeamB)
0
Luiz
2/10/2015 10:27:26 PM
Mr Remy,

These are the Headers showing in SOAP. I copied them to IdHttp but the error is the same.

{code}
POST https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
Content-Length: 4463
Host: wsp.hom.orizonbrasil.com.br:6214
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.ans.gov.br/padroes/tiss/schemas" xmlns:xd="http://www.w3.org/2000/09/xmldsig#">
   <soapenv:Header/>
   <soapenv:Body>
      <sch:solicitacaoProcedimentoWS>
         <sch:cabecalho>
            <sch:identificacaoTransacao>
               <sch:tipoTransacao>SOLICITACAO_PROCEDIMENTOS</sch:tipoTransacao>
               <sch:sequencialTransacao>k1</sch:sequencialTransacao>
               <sch:dataRegistroTransacao>2015-01-30</sch:dataRegistroTransacao>
               <sch:horaRegistroTransacao>16:55:00</sch:horaRegistroTransacao>
            </sch:identificacaoTransacao>
             <sch:origem>

{code}

Here is my delphi code:

{code}
procedure TForm5.Button3Click(Sender: TObject);
var
  Req: TStream;
  SL: TStringList;
  S: String;
  SSL1 : TIdSSLIOHandlerSocketOpenSSL;
begin
  Req := TStringStream.Create(Memo1.Text, TEncoding.UTF8);
  try
    SSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
    try
      SSL1.SSLOptions.Method := sslvSSLv23;
      IdHTTP1.IOHandler := SSL1;
      IdHTTP1.Request.ContentType := 'text/xml';
      IdHTTP1.Request.Charset := 'UTF-8';
      IdHTTP1.Request.AcceptEncoding:='gzip,deflate';
      IdHTTP1.Request.Connection:='Keep-Alive';
      IdHTTP1.Request.UserAgent:='Apache-HttpClient/4.1.1 (java 1.5)';
     IdHTTP1.Request.RawHeaders.Add('SOAPAction: ""');

      S := IdHTTP1.Post('https://wsp.hom.orizonbrasil.com.br:6214/tiss/v30200/tissSolicitacaoProcedimento',
Req);
    finally
      SSl1.Free;
    end;
  finally
    Req.Free;
  end;

  MemoResp.Lines.Add(Format('Response Code: %d', [IdHTTP1.ResponseCode]));
  MemoResp.Lines.Add(Format('Response Text: %s', [IdHTTP1.ResponseText]));

  SL := TStringList.Create;
  try
    SL.Text := S;
    MemoResp.Lines.AddStrings(SL);
  finally
    SL.Free;
  end;
end;
{code}


> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> Luiz wrote:
> 
> > I have tried your two suggestions, but the result is the same. I
> > still have the same  "HTTP/1.0 500 Error"
> 
> Then either your SOAP XML is malformed, or you are not posting everything 
> that the webservice is expecting (for instance, are you setting the SOAP-related 
> HTTP headers anywhere in your code? You did not show that).  You could use 
> a debugging proxy, such as Fiddler, to compare the requests of SOAPUI and 
> TIdHTTP to see what is different between them, otherwise have the site admin
> debug the webservice and find out why it is returning 500, and then update your
> TIdHTTP  code accordingly.
> 
> -- 
> Remy Lebeau (TeamB)

Edited by: Luiz Oliveira on Feb 10, 2015 2:27 PM
0
Luiz
2/10/2015 10:27:43 PM
Luiz wrote:

> IdHTTP1.Request.AcceptEncoding:='gzip,deflate';

Don't set those values manually.  TIdHTTP manages that internally as needed. 
 If you want to support compression, you have to assign a compressor component 
to the TIdHTTP.Compressor property, then TIdHTTP will enable gzip and deflate 
compression.

> IdHTTP1.Request.RawHeaders.Add('SOAPAction: ""');

You need to use the CustomHeaders property instead of the RawHeaders property, 
and you should use the AddValue() method:

{code}
IdHTTP1.Request.CustomHeaders.AddValue('SOAPAction', '""');
{code}

With that said, did you verify that TIdHTTP is transmitting the SOAP XML 
*exactly* the same way that SOAPUI does?  It should be.

If you are STILL having the same problem, then this is likely going to turn 
out to be an SSL problem, not a TIdHTTP problem.  The fact that WinInet complains 
about a missing certificate is suspicious.  You really need to have the site 
admin debug the webservice on the server side and find out exactly what is 
failing.  That should be easy if the server is logging error information. 
 I would also suggest you use Wireshark to debug the SSL handshakes that 
SOAPUI and TIdHTTP are both sending.  You are getting a valid HTTP response, 
so clearly a secure session is being estalbished, but maybe the webservice 
is configured to validate client certificates.  You have to talk to the site 
admin about that.

-- 
Remy Lebeau (TeamB)
0
Remy
2/10/2015 11:24:18 PM
Mr Remy,

I was doing copy and past from SOAPUI to TMemo in Delphi.
for some reason I still do not know, the copy was corrupted.

Now, all is working with idHTTP.

I did tests with SOAP units compiled with Indy and all works great.

With SOAP WinInet compiled Units, the app always getg error about certificate required.

To compile SOAP Units with Indy, I copied soap units from delphi source to local app folder of my app and   I edited   Soap.SOAPHTTPTrans commenting  NEXTGEN as showing here. 
Could you tell me if this is the right way to do this ?

Very thanks for your help.

Luiz
{code}
unit Soap.SOAPHTTPTrans;

{$IF CompilerVersion >= 24.0}
{$LEGACYIFEND ON}
{$IFEND}

{$IFDEF POSIX}
  {$DEFINE USE_INDY}
{$ENDIF}
{$IFDEF MSWINDOWS}
 {.$IFDEF NEXTGEN}
  {$DEFINE USE_INDY}
 {.$ENDIF}
{$ENDIF}

{code}

> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> Luiz wrote:
> 
> > IdHTTP1.Request.AcceptEncoding:='gzip,deflate';
> 
> Don't set those values manually.  TIdHTTP manages that internally as needed. 
>  If you want to support compression, you have to assign a compressor component 
> to the TIdHTTP.Compressor property, then TIdHTTP will enable gzip and deflate 
> compression.
> 
> > IdHTTP1.Request.RawHeaders.Add('SOAPAction: ""');
> 
> You need to use the CustomHeaders property instead of the RawHeaders property, 
> and you should use the AddValue() method:
> 
> {code}
> IdHTTP1.Request.CustomHeaders.AddValue('SOAPAction', '""');
> {code}
> 
> With that said, did you verify that TIdHTTP is transmitting the SOAP XML 
> *exactly* the same way that SOAPUI does?  It should be.
> 
> If you are STILL having the same problem, then this is likely going to turn 
> out to be an SSL problem, not a TIdHTTP problem.  The fact that WinInet complains 
> about a missing certificate is suspicious.  You really need to have the site 
> admin debug the webservice on the server side and find out exactly what is 
> failing.  That should be easy if the server is logging error information. 
>  I would also suggest you use Wireshark to debug the SSL handshakes that 
> SOAPUI and TIdHTTP are both sending.  You are getting a valid HTTP response, 
> so clearly a secure session is being estalbished, but maybe the webservice 
> is configured to validate client certificates.  You have to talk to the site 
> admin about that.
> 
> -- 
> Remy Lebeau (TeamB)
0
Luiz
2/11/2015 1:01:01 AM
Mr Remy,

I was doing copy and past from SOAPUI request message to TMemo in Delphi.
for some reason I still do not know, the copy was corrupted.

Now, all is working with idHTTP.

I did tests with SOAP units compiled with Indy and all works great.

With SOAP WinInet compiled Units, the app always getg error about certificate required.

To compile SOAP Units with Indy, I copied soap units from delphi source to local app folder of my app and   I edited   Soap.SOAPHTTPTrans commenting  NEXTGEN as showing here. 
Could you tell me if this is the right way to do this ?

Very thanks for your help.

Luiz
{code}
unit Soap.SOAPHTTPTrans;

{$IF CompilerVersion >= 24.0}
{$LEGACYIFEND ON}
{$IFEND}

{$IFDEF POSIX}
  {$DEFINE USE_INDY}
{$ENDIF}
{$IFDEF MSWINDOWS}
 {.$IFDEF NEXTGEN}
  {$DEFINE USE_INDY}
 {.$ENDIF}
{$ENDIF}

{code}

> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> Luiz wrote:
> 
> > IdHTTP1.Request.AcceptEncoding:='gzip,deflate';
> 
> Don't set those values manually.  TIdHTTP manages that internally as needed. 
>  If you want to support compression, you have to assign a compressor component 
> to the TIdHTTP.Compressor property, then TIdHTTP will enable gzip and deflate 
> compression.
> 
> > IdHTTP1.Request.RawHeaders.Add('SOAPAction: ""');
> 
> You need to use the CustomHeaders property instead of the RawHeaders property, 
> and you should use the AddValue() method:
> 
> {code}
> IdHTTP1.Request.CustomHeaders.AddValue('SOAPAction', '""');
> {code}
> 
> With that said, did you verify that TIdHTTP is transmitting the SOAP XML 
> *exactly* the same way that SOAPUI does?  It should be.
> 
> If you are STILL having the same problem, then this is likely going to turn 
> out to be an SSL problem, not a TIdHTTP problem.  The fact that WinInet complains 
> about a missing certificate is suspicious.  You really need to have the site 
> admin debug the webservice on the server side and find out exactly what is 
> failing.  That should be easy if the server is logging error information. 
>  I would also suggest you use Wireshark to debug the SSL handshakes that 
> SOAPUI and TIdHTTP are both sending.  You are getting a valid HTTP response, 
> so clearly a secure session is being estalbished, but maybe the webservice 
> is configured to validate client certificates.  You have to talk to the site 
> admin about that.
> 
> -- 
> Remy Lebeau (TeamB)

Edited by: Luiz Oliveira on Feb 11, 2015 3:28 PM
0
Luiz
2/11/2015 11:28:25 PM
Mr Remy,

I was doing copy and past from SOAPUI request message to TMemo in Delphi.
for some reason I still do not know, the copy was corrupted.

Now, all is working with idHTTP.

I did tests with SOAP units compiled with Indy and all works great.

With SOAP WinInet compiled Units, the app always getg error about certificate required.

To compile SOAP Units with Indy, I copied soap units from delphi source to local app folder  and  I edited   Soap.SOAPHTTPTrans commenting  NEXTGEN as showing here. 
Could you tell me if this is the right way to do this ?

Very thanks for your help.

Luiz
{code}
unit Soap.SOAPHTTPTrans;

{$IF CompilerVersion >= 24.0}
{$LEGACYIFEND ON}
{$IFEND}

{$IFDEF POSIX}
  {$DEFINE USE_INDY}
{$ENDIF}
{$IFDEF MSWINDOWS}
 {.$IFDEF NEXTGEN}
  {$DEFINE USE_INDY}
 {.$ENDIF}
{$ENDIF}

{code}

> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> Luiz wrote:
> 
> > IdHTTP1.Request.AcceptEncoding:='gzip,deflate';
> 
> Don't set those values manually.  TIdHTTP manages that internally as needed. 
>  If you want to support compression, you have to assign a compressor component 
> to the TIdHTTP.Compressor property, then TIdHTTP will enable gzip and deflate 
> compression.
> 
> > IdHTTP1.Request.RawHeaders.Add('SOAPAction: ""');
> 
> You need to use the CustomHeaders property instead of the RawHeaders property, 
> and you should use the AddValue() method:
> 
> {code}
> IdHTTP1.Request.CustomHeaders.AddValue('SOAPAction', '""');
> {code}
> 
> With that said, did you verify that TIdHTTP is transmitting the SOAP XML 
> *exactly* the same way that SOAPUI does?  It should be.
> 
> If you are STILL having the same problem, then this is likely going to turn 
> out to be an SSL problem, not a TIdHTTP problem.  The fact that WinInet complains 
> about a missing certificate is suspicious.  You really need to have the site 
> admin debug the webservice on the server side and find out exactly what is 
> failing.  That should be easy if the server is logging error information. 
>  I would also suggest you use Wireshark to debug the SSL handshakes that 
> SOAPUI and TIdHTTP are both sending.  You are getting a valid HTTP response, 
> so clearly a secure session is being estalbished, but maybe the webservice 
> is configured to validate client certificates.  You have to talk to the site 
> admin about that.
> 
> -- 
> Remy Lebeau (TeamB)

Edited by: Luiz Oliveira on Feb 11, 2015 3:28 PM

Edited by: Luiz Oliveira on Feb 11, 2015 3:28 PM
0
Luiz
2/11/2015 11:29:08 PM
Reply:

Similar Artilces:

Error HTTP/1.1 500 Internal Server Error with Indy FireDac DataSnap XE7
*I made a server application that calling the methods by browse, everything works perfect,* *but to test my methods build a client using TdHTTP it and call the methods as follows:* procedure TF_CLIENTE.SBEnviar2Click(Sender: TObject); var Url : String; lJSO : String; jsonToSend : TStringStream; begin Url := 'http://localhost:809...ecomandoPOST/'; lJSO := ('{"name":"TESTE"}'); jsonToSend := TStringStream.Create(lJSO,TEncoding.UTF8); idHttp.ProxyParams...

Start up error: HTTP/1.1 500 Server Error
I recieved the following error when trying to create a program'The web server reported the following error when attempting to create or the open the Web project located at the following URL: http://localhost/asptest 'HTTP/1.1 500 Server Error'here are the event viewer errors:Event Type: ErrorEvent Source: DCOMEvent Category: NoneEvent ID: 10004Date:  10/27/2008Time:  2:05:36 PMUser:  N/AComputer: LNOxxxxCFD2YDescription:DCOM got error "Logon failure: the user has not been granted the requested logon type at this computer...

Got an Error HTTP/1.1 500 Server Error
Hi is there anybody can help me with my problem in asp.net... coz everytime i open .net and create new asp files i got an error of "The Web server reported the following error when attempting to create or open the web project located at the following URL: 'http://pc03/localhost/MyWeb/Application'.'HTTP/1.1 500 Server Error'. thanks... pilots Have you turned off Friendly Errors in Tools | Internet Options | Advanced. Usually this is the problem. Corey...

HTTP/1.1 500 Error
I am getting the above error, with the message "Server not available."  I have a hunch that the problem can be traced to a patch I installed this month.  The patch (SP2DBFix1.1.1.mxp) was supposed to correct an interaction problem between Dreamweaver and Asp.Net.History:  Everything in Visual Studio worked just fine last semester, when I took the Asp.Net class.  Now, none of the Asp.Net applications work, although the VB.Net apps in my Visual Studio still work as expected.  Help, please!Dee Start by finding the real error:http://www.aspfaq.com/show.asp?id=2109JeffP...

Start up Error: HTTP/1.1 500 Internal server Error
When I attempt to create a new project or open an existing one, I recieve the following error.  "The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/PROJECTNAME'.  'HTTP/1.1 500 Internal server Error'. Now I have a fix for this, but it requires me to have to do it everytime I reboot my computer.  It's kind of a lengthy process and I've looked just about everywhere for perm. fixes for this error but have come up empty.  I've had just about enough of d...

HTTP 1.0 500 server error
Hi guys I have installed iis and vb.net on my home computer. and i'm trying to make a web applaction but Visual Studio wont let me. I keep on getting this error message. "The web server reported the following error when attempting to create or open the web project located at the following URL: 'http://localhost/webtest'. HTTP/1.0 500 Server Error. I have tomcat also installed on my computer could that be one of the problems. Can somebody please help me. Cylus Hi, did you first install IIS and after that the .NET framework or in the reverse order? In the former case you can try...

HTTP/1.0 500 server Error problem
I have started to make a web page for my self. I have been working on it for 3 days and I tried to work on it today and i get the error message. The web server reported the following error when attempting to create or open the web project located at the following URL: 'http://localhost/cylus101', 'HTTP/1.0 500 server Error'. what can i do to fix this problem. Please somebody help me. Thanx Cylus sounds like an asp script error... try loading it up from mozilla firefox and it will tell you what line you went wrong at Hi, 500 means an internal server error. Check out ...

http://localhost/WebProject1', 'HTTP/1.1 500 Server Error'.
The Web server reported the following error when attempting tocreate or open the Web project located at the following URL:'http://localhost/WebProject1', 'HTTP/1.1 500 Server Error'.i am using xp professional,sql 7.0,.net 1.1                       PLEASE HELP ME                                    ...

Server error running asp.net 'HTTP/1.1 500 Server Error'
. can anyone help? First, is this ASP.NET or ASP Classic, there is a difference and ASP.NET wouldn't normally use the IWAM account.  The answer to your issue is usually this: http://support.microsoft.com/kb/276407 JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue. this is ASP.Net, trying to create projects in VS 2003.  I recieve that error. PLEASE HELP VS is uesless to me unless I get this issue fixed!! Hi, It seems that there are two versions of ASP.NET to ...

HTTP 1.1/500 Server Error
Hello all, I have .NET working swimmingly on my Win 2K laptop. I'm in the process of trying to get it working on my home PC, running Win XP Pro. IIS installed fine, .NET framework and the software installed fine, but here's the situation. Whenever I try to create a new web application in Vis Studio .NET 2003, I get the following error: The web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/test'. HTTP 1.1/500 Server Error'. I did some further testing, and found the following: -IIS is up, and...

http/1.1 500 Server Error
  Hi all.. http/1.1 500 Server Error Wat to do to resolve this??? I tried a lot. I cannot open or create a web application. Unistall and reinstall the framework. Done a lot browsing the web. But still the same problem. Can anyone help meRegards,Jeen Please give us some more informationWhat version of OS, IIS, ASP.NET are you using?How did you deploy the website and what settings is your virtual directory running as?  Did you check the Event logs...? JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers wil...

HTTP/1.1 500 Server Error
please help today I instaled MS IIS, MS Framework 1.1 and MS Visual Studio .NET 2003 When I try to create new project (ASP.NET Web Application) on localhost it gives error message. I runned the aspnet_regiis.exe -i already, but it didn't help ...

HTTP/1.0.425 HTTP Error
Hi, I have written a webservice to access data from the host. All these days it worked fine, but now i am not able to open the ASP.NET Web application/service. It throws an error 'The Web server reported the following error when attempting to create or open the project located at the following url 'http://localhost/abcd'. HTTP/1.0.425 HTTP Error'. I have re-installed the .NET Framework and IIS. Also restarted the services and machine too but no use. i cannot spend time in installing the .net from the scratch. Please help me in finding the solution for this. Thanks and ...

HTTP/1.1 500 Server Error
I am doing a mobile application via Visual Studio.Net 2003 and encounter this error message: " The Web server reported the following error when attemping to create or open the Web project located at the following URL: 'http://localhost.MobileWebApplication1'.'HTTP/1.1 500 Server Error' when I tried to open my project file or start a new project. How can I debug this error? Please help. Googling your question I found: "When you create a Web Application project, Visual Studio creates the default project settings for debugging. When you choose Start from the Debug menu, ...

HTTP/1.1 500 Server Error
I installed VS2003 on my pc but when i try to create a new project http://localhost/xyz/webapplication1 it gives HTTP/1.1 500 Server Error.  anyone have idea on whats wrong?  I repaired vs2003, reinstalled iis but still getting this error.  ...

Web resources about - Indy https post returns HTTP/1.0 500 Error - help - embarcadero.delphi.winsock

Sample return mission - Wikipedia, the free encyclopedia
A sample return mission is a spacecraft mission with the goal of returning tangible samples from an extraterrestrial location to Earth for analysis. ...

Sydney prepares for return to summer as region mops up after wild weather
Sydney will begin to reclaim summer as those left stranded and soggy used a break in the wild weather to start mopping up.

Jarryd Hayne returns to Sydney but won't take break from learning the NFL ropes
San Francisco 49ers running back Jarryd Hayne arrived back in Sydney on Wednesday after his first season in the NFL but he's still looking to ...

Maria Bartiromo, Neil Cavuto Return for FBN’s 2nd GOP Debate
Neil Cavuto and Maria Bartiromo will return as moderators of the next GOP debate, to be held Jan. 14 on FBN. For the earlier, lower-tier debate, ...

A portfolio that's doubled index return
Should a smart investor stick with stock winners or bet on a turnaround in dogs? A new study reveals the answer.

Monster Unveils New Headphones, Declares Return Of Boombox, Teases Partnership With Bentley
After taking a break from his high-energy emceeing duties at CES 2015 , Monster CEO Noel Lee (and his blinged-out Segway) returned to the CES ...

DC Youth Worker Got $4M From IRS With Fake Tax Returns
DC Youth Worker Got $4M From IRS With Fake Tax Returns

ISIS Gone, Archaeologists Return to Key Iraq Sites
As ISIS is pushed out of northern Iraq, archaeologists are returning to the area, including at the Neanderthal site in Shanidar Cave.

Pakistani Tea House Revamp, the Return of Rodeo Bar, and More Intel
Heat was restored to the Carnegie Deli building, plus more news and gossip from around NYC. — The Pakistani Tea House at 172 Church Street has ...

High Return On Invested Capital: One Metric Shared By Top Stocks
... Fortune released its list of the top 50 businesspeople of the year, according to their measures of profitability, growth, shareholder return, ...

Resources last updated: 1/7/2016 7:21:55 AM