SOAP client delphi 2010 parse [Edit]

I'm desperately trying to use SOAP services. I
 had no problems to import the structure by WSDL import. 
The code I use to the service call is as follows: 

 var 
    ser: SearchContrattoInDTO; 
    att: attestazioniSoaPortType; 
    s: String; 
begin 
  ser: = SearchContrattoInDTO.Create; 
  ser.codiceSOA: = '10 '; 
  ser.numContratto: = '002 '; 

  att: = GetattestazioniSoaPortType (false,'', HTTPRIO1); 
  try 
    s: = att.getContrattoFull (ser).messaggio; 
    except on E: Exception do 
          MessageDlg (E. Message, mtError [Mboka], 0); 
  end; 

 It generates an exception of type 

 EDOMParseError: "Invalid at the top level of document  Line 1 --MIMEBoundaryurn_uuid_2BBB929C9F381AC14C1299861024073 " 

 The response is still correct. This is the reply received. 

--MIMEBoundaryurn_uuid_2BBB929C9F381AC14C1299861024073
Content-Type: application/soap+xml; charset=utf-8
Content-Transfer-Encoding: 8bit
Content-ID: <0.urn:uuid:2BBB929C9F381AC14C1299861024074@apache.org>

<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns:getContrattoFullResponse xmlns:ns="http://services.at.avcp.it"><ns:return xmlns:ax21="http://in.dto.at.avcp.it/xsd" xmlns:ax23="http://out.dto.at.avcp.it/xsd" xmlns:ax24="http://dto.at.avcp.it/xsd" type="it.avcp.at.dto.out.ContrattiOutDTO"><ax23:contratto xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /><ax23:codice>getContrattoFull</ax23:codice><ax23:esit
o>-1</ax23:esito><ax23:messaggio>getContrattoFull:: Il contratto non e' stato trovato</ax23:messaggio></ns:return></ns:getContrattoFullResponse></soapenv:Body></soapenv:Envelope>
--MIMEBoundaryurn_uuid_2BBB929C9F381AC14C1299861024073--

I think the Parser does not work because  the answer is interpreted as a 
attachmentche really is not or something like that .. 

It 's the first time i use the SOAP web services. 
Please help...

Edited by: Bruno Lorenzo on Mar 11, 2011 8:38 AM
0
Bruno
3/11/2011 4:40:29 PM
embarcadero.delphi.webservices 976 articles. 0 followers. Follow

9 Replies
2319 Views

Similar Articles

[PageSpeed] 32

Hello,
> It generates an exception of type
>
> EDOMParseError: "Invalid at the top level of document  Line 
> 1 --MIMEBoundaryurn_uuid_2BBB929C9F381AC14C1299861024073 "
>
> The response is still correct. This is the reply received.
>
> --MIMEBoundaryurn_uuid_2BBB929C9F381AC14C1299861024073
> Content-Type: application/soap+xml; charset=utf-8
> Content-Transfer-Encoding: 8bit
> Content-ID: <0.urn:uuid:2BBB929C9F381AC14C1299861024074@apache.org>
>
> <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope 
> xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns:getContrattoFullResponse 
> xmlns:ns="http://services.at.avcp.it"><ns:return 
> xmlns:ax21="http://in.dto.at.avcp.it/xsd" 
> xmlns:ax23="http://out.dto.at.avcp.it/xsd" 
> xmlns:ax24="http://dto.at.avcp.it/xsd" 
> type="it.avcp.at.dto.out.ContrattiOutDTO"><ax23:contratto 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" 
> /><ax23:codice>getContrattoFull</ax23:codice><ax23:esit
> o>-1</ax23:esito><ax23:messaggio>getContrattoFull:: Il contratto non e' 
> stato 
> trovato</ax23:messaggio></ns:return></ns:getContrattoFullResponse></soapenv:Body></soapenv:Envelope>
> --MIMEBoundaryurn_uuid_2BBB929C9F381AC14C1299861024073--
>
> I think the Parser does not work because  the answer is interpreted as a
> attachmentche really is not or something like that ..
>

It seems that it's the other way: the SOAP runtime is not expecting 
MultiPart/MIME but that's what the Service is sending back. I wish we could 
see the whole response - i.e. with the HTTP headers. That's how the Delphi 
runtime will try to determine if the response is MultiPart or not. 
Interestingly I don't see the reason why the Server sent the response this 
way because the XML response (which is always in the first part) does not 
make any references to other parts.

Two questions:
===========
1. Can you capture the whole response - include HTTP headers - using 
something like WireShark/Ethereal. You can even use something like 
proxyTrace and configure WinInet to use it. I'd like to see the HTTP headers 
that came back with the response to determine why the Delphi runtime did not 
detect multipart and instead pass the whole thing to the XML parser [which, 
as expected, did not like the MIME boundary].

2. If the above does not work, can you point me to the WSDL of the Service? 
I'd like to see there's any hint there about Attachments/MTOM/??

If possible, do post the signature that the importer gave you for that 
method. Thank you.

Cheers,

Bruneau
0
Jean
3/11/2011 10:44:13 PM
> {quote:title=Jean-Marie Babet wrote:}{quote}
> Hello,
> > It generates an exception of type
> >
> > EDOMParseError: "Invalid at the top level of document  Line 
> > 1 --MIMEBoundaryurn_uuid_2BBB929C9F381AC14C1299861024073 "
> >
> > The response is still correct. This is the reply received.
> >
> > --MIMEBoundaryurn_uuid_2BBB929C9F381AC14C1299861024073
> > Content-Type: application/soap+xml; charset=utf-8
> > Content-Transfer-Encoding: 8bit
> > Content-ID: <0.urn:uuid:2BBB929C9F381AC14C1299861024074@apache.org>
> >
> > <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope 
> > xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns:getContrattoFullResponse 
> > xmlns:ns="http://services.at.avcp.it"><ns:return 
> > xmlns:ax21="http://in.dto.at.avcp.it/xsd" 
> > xmlns:ax23="http://out.dto.at.avcp.it/xsd" 
> > xmlns:ax24="http://dto.at.avcp.it/xsd" 
> > type="it.avcp.at.dto.out.ContrattiOutDTO"><ax23:contratto 
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" 
> > /><ax23:codice>getContrattoFull</ax23:codice><ax23:esit
> > o>-1</ax23:esito><ax23:messaggio>getContrattoFull:: Il contratto non e' 
> > stato 
> > trovato</ax23:messaggio></ns:return></ns:getContrattoFullResponse></soapenv:Body></soapenv:Envelope>
> > --MIMEBoundaryurn_uuid_2BBB929C9F381AC14C1299861024073--
> >
> > I think the Parser does not work because  the answer is interpreted as a
> > attachmentche really is not or something like that ..
> >
> 
> It seems that it's the other way: the SOAP runtime is not expecting 
> MultiPart/MIME but that's what the Service is sending back. I wish we could 
> see the whole response - i.e. with the HTTP headers. That's how the Delphi 
> runtime will try to determine if the response is MultiPart or not. 
> Interestingly I don't see the reason why the Server sent the response this 
> way because the XML response (which is always in the first part) does not 
> make any references to other parts.
> 
> Two questions:
> ===========
> 1. Can you capture the whole response - include HTTP headers - using 
> something like WireShark/Ethereal. You can even use something like 
> proxyTrace and configure WinInet to use it. I'd like to see the HTTP headers 
> that came back with the response to determine why the Delphi runtime did not 
> detect multipart and instead pass the whole thing to the XML parser [which, 
> as expected, did not like the MIME boundary].
> 
> 2. If the above does not work, can you point me to the WSDL of the Service? 
> I'd like to see there's any hint there about Attachments/MTOM/??
> 
> If possible, do post the signature that the importer gave you for that 
> method. Thank you.
> 
> Cheers,
> 
> Bruneau

Hello,
Thank you very much for your interest, sorry for the delay but I was abroad in those days. 

From wireShark:

+This is the request+ 
6	0.057956	sviluppo.domattesta.attesta.lc	ppp188-1-13-151-13as58mi1.iunet.it	HTTP/XML	POST /attestazioniWS_1.2/services/attestazioniSoa.attestazioniSoaHttpSoap12Endpoint/ HTTP/1.1 

POST /attestazioniWS_1.2/services/attestazioniSoa.attestazioniSoaHttpSoap12Endpoint/ HTTP/1.1
SOAPAction: "urn:getContrattoFull"
Content-Type: text/xml; charset="utf-8"
User-Agent: CodeGear SOAP 1.3
Host: servizisoa.avcp.it:8080
Content-Length: 727
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: JSESSIONID=AED4CEFF9EC81B08380217564FEEBB6F
Authorization: Basic TU5URE5DNzRBMDdFOTg2Qjpkb21lVlNyaw==

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS2="http://in.dto.at.avcp.it/xsd"><NS1:getContrattoFull xmlns:NS1="http://services.at.avcp.it"><searchCriteria href="#1"/></NS1:getContrattoFull><NS2:SearchContrattoInDTO id="1" xsi:typ
e="NS2:SearchContrattoInDTO"><codiceSOA xsi:type="xsd:string">7</codiceSOA><numContratto xsi:type="xsd:string">001</numContratto></NS2:SearchContrattoInDTO></SOAP-ENV:Body></SOAP-ENV:Envelope>

+This is the response+

11	0.178707	ppp188-1-13-151-13as58mi1.iunet.it	sviluppo.domattesta.attesta.lc	HTTP/XML	HTTP/1.1 200 OK 

HHTTP/1.1 200 OK

Server: Apache-Coyote/1.1

Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_2BBB929C9F381AC14C1300207907109; type="text/xml"; start="<0.urn:uuid:2BBB929C9F381AC14C1300207907110@apache.org>"

Transfer-Encoding: chunked

Date: Tue, 15 Mar 2011 16:51:46 GMT



379

--MIMEBoundaryurn_uuid_2BBB929C9F381AC14C1300207907109

Content-Type: text/xml; charset=utf-8

Content-Transfer-Encoding: 8bit

Content-ID: <0.urn:uuid:2BBB929C9F381AC14C1300207907110@apache.org>



<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:getContrattoFullResponse xmlns:ns="http://services.at.avcp.it"><ns:return xmlns:ax21="http://in.dto.at.avcp.it/xsd" xmlns:ax23="http://out.dto.at.avcp.it/xsd" xmlns:ax24="http://dto.at.avcp.it/xsd" type="it.avcp.at.dto.out.ContrattiOutDTO"><ax23:contratto xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /><ax23:codice>getContrattoFull</ax23:codice><ax23:es
ito>-1</ax23:esito><ax23:messaggio>getContrattoFull:: Il contratto non e' stato trovato</ax23:messaggio></ns:return></ns:getContrattoFullResponse></soapenv:Body></soapenv:Envelope>

38



--MIMEBoundaryurn_uuid_2BBB929C9F381AC14C1300207907109

2

--

0

This is the wsdl location http://servizisoa.avcp.it:8080/attestazioniWS_1.2/services/attestazioniSoa?wsdl

I've noticed that the wdsl importer give me this adresses

 // ************************************************************************ //
  // Namespace : http://services.at.avcp.it
  // soapAction: urn:%operationName%
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // binding   : attestazioniSoaSoap12Binding
  // service   : attestazioniSoa
  // port      : attestazioniSoaHttpSoap12Endpoint
  // URL       : *http://10.119.128.211*:8080/attestazioniWS_1.2/services/attestazioniSoa.attestazioniSoaHttpSoap12Endpoint/
but 10.119.128.211 is a local address, so i've to change the const defURL  in the function GetattestazioniSoaPortType(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): attestazioniSoaPortType;  from 10.119.128.211  to "services.at.avcp.it" and use something like 
"att:=GetattestazioniSoaPortType(false,'',HTTPRIO1);"
and not  "att:=GetattestazioniSoaPortType;"  as it can't work. I do not know if this really matter however..

Cheers
Bruno

Edited by: Bruno Lorenzo on Mar 15, 2011 10:07 AM
0
Bruno
3/15/2011 5:07:32 PM
Hello,

Thanks for the additional information. The issue in this case is that the 
runtime is not expecting the response in multipart/related format. But it 
should be handle to handle it and simply extract the SOAP envelope from the 
first part. If time allows could you try the following and let me know what 
you find out as I'm trying to locate the failure point:

1. Add SOAPHTTPTrans.pas and RIO.pas to your project (you might want to copy 
these files from $(BDS)\source\soap to your project's directory).

2. See a breakpoint in THTTPReqResp.Receive (SOAPHTTPTrans.pas) on this 
line:


{code}
  { Ask for Content-Type }
  Size := MaxContentType;
  SetLength(FContentType, MaxContentType);
  HttpQueryInfo(Pointer(Context), HTTP_QUERY_CONTENT_TYPE, @FContentType[1], 
Size, Index);
  SetLength(FContentType, Size div sizeof(Char));

  { Extract Mime-Boundary }
  FMimeBoundary := GetMimeBoundaryFromType(FContentType);   /// BREAKPOINT 
HERE

  { Read data }
{code}

On my setup it's line 758. I'm curious about the value of FContentType and 
whether we correctly retrieve a MimeBoundary. If yes, the code in RIO should 
proceed with multipart handling. I suspect we fail there. But it's not clear 
to me whether that's the case or not.

3. The next relevant point, if the above succeeds in retrieve a 
MIMEBoundary, would be in RIO.pas:


{code}
{$IFDEF ATTACHMENT_SUPPORT}
          { If we're expecting MIME parts, process 'em }
          if FWebNode.MimeBoundary <> '' then    // BREAKPOINT HERE
          begin
            AttachHandler.ProcessMultiPartForm(Resp, XMLStream, 
FWebNode.MimeBoundary, Nil,
                                               FConverter.Attachments, 
FConverter.TempDir);
            { Now point RespXML to Envelope }
            RespXML := XMLStream;
          end;
{$ENDIF}
          FConverter.ProcessResponse(RespXML, IntfMD, MethMD, FContext, 
FHeadersInbound);
{code}


That's on line 961 on my setup. Let me know if you go through 
ProcessMultipPartForm and reset the RespXML stream.

Thank you!

Cheers,

Bruneau
0
Jean
3/17/2011 11:39:54 PM
> {quote:title=Jean-Marie Babet wrote:}{quote}
> Hello,
> 
> Thanks for the additional information. The issue in this case is that the 
> runtime is not expecting the response in multipart/related format. But it 
> should be handle to handle it and simply extract the SOAP envelope from the 
> first part. If time allows could you try the following and let me know what 
> you find out as I'm trying to locate the failure point:
> 
> 1. Add SOAPHTTPTrans.pas and RIO.pas to your project (you might want to copy 
> these files from $(BDS)\source\soap to your project's directory).
> 
> 2. See a breakpoint in THTTPReqResp.Receive (SOAPHTTPTrans.pas) on this 
> line:
> 
> 
> {code}
>   { Ask for Content-Type }
>   Size := MaxContentType;
>   SetLength(FContentType, MaxContentType);
>   HttpQueryInfo(Pointer(Context), HTTP_QUERY_CONTENT_TYPE, @FContentType[1], 
> Size, Index);
>   SetLength(FContentType, Size div sizeof(Char));
> 
>   { Extract Mime-Boundary }
>   FMimeBoundary := GetMimeBoundaryFromType(FContentType);   /// BREAKPOINT 
> HERE
> 
>   { Read data }
> {code}
> 
> On my setup it's line 758. I'm curious about the value of FContentType and 
> whether we correctly retrieve a MimeBoundary. If yes, the code in RIO should 
> proceed with multipart handling. I suspect we fail there. But it's not clear 
> to me whether that's the case or not.
> 
> 3. The next relevant point, if the above succeeds in retrieve a 
> MIMEBoundary, would be in RIO.pas:
> 
> 
> {code}
> {$IFDEF ATTACHMENT_SUPPORT}
>           { If we're expecting MIME parts, process 'em }
>           if FWebNode.MimeBoundary <> '' then    // BREAKPOINT HERE
>           begin
>             AttachHandler.ProcessMultiPartForm(Resp, XMLStream, 
> FWebNode.MimeBoundary, Nil,
>                                                FConverter.Attachments, 
> FConverter.TempDir);
>             { Now point RespXML to Envelope }
>             RespXML := XMLStream;
>           end;
> {$ENDIF}
>           FConverter.ProcessResponse(RespXML, IntfMD, MethMD, FContext, 
> FHeadersInbound);
> {code}
> 
> 
> That's on line 961 on my setup. Let me know if you go through 
> ProcessMultipPartForm and reset the RespXML stream.
> 
> Thank you!
> 
> Cheers,
> 
> Bruneau

Hello, 
I really thank you for your interest.
 
Summary:
 
I'm using delphi2010 and source files SOAPHTTPTrans.pas and RIO.pas seems not distributed in source code. 

However, I've tried to write code using Delphi 2007.
 
Incredibly, with Delphi 2007 it works perfectly!! The parser  returns the correct answers. 

Now, I would not, however,  downgrade my project to 2007, obviously there is some problem in delphi 2010, i've also tried with a new demo version of delphiXE and there is the same problem.

But I can't put those breakpoints as I do not have the source code for  SOAPHTTPTrans and  RIO. 

I also tried to use the file generated by wsdl importer of Delphi 2007 into my Delphi 2010 project, but it do not work.

 the object HTTPRIO1 are identical in delphi 2007 and delphi 2010:

 object HTTPRIO1: THTTPRIO
    OnAfterExecute = HTTPRIO1AfterExecute
    OnBeforeExecute = HTTPRIO1BeforeExecute
    WSDLLocation =
      'http://servizisoa.avcp.it:8080/attestazioniWS_1.2/services/attes' +
      'tazioniSoa?wsdl'
    Service = 'attestazioniSoa'
    Port = 'attestazioniSoaHttpSoap12Endpoint'
    HTTPWebNode.UserName = 'pincopallo'
    HTTPWebNode.Password = 'testsoa'
    HTTPWebNode.UseUTF8InHeader = True
    HTTPWebNode.InvokeOptions = [soIgnoreInvalidCerts, soAutoCheckAccessPointViaUDDI]
    Converter.Options = [soSendMultiRefObj, soTryAllSchema, soRootRefNodesToBody, soCacheMimeResponse, soUTF8EncodeXML]

Thank you!

Cheers,

Bruno
0
Bruno
3/18/2011 4:37:06 PM
Hello,


> However, I've tried to write code using Delphi 2007.
>
> Incredibly, with Delphi 2007 it works perfectly!! The parser  returns the 
> correct answers.

Ummm... this makes me suspect that you might be running in the SOAPAttach 
problem I noticed recently and mentioned here:

  https://forums.embarcadero.com/message.jspa?messageID=328727#328727

In that particular case, the problem was a Delphi Service not properly 
handling a MultiPart request but it's the same code that's used by a Client 
to handle a MultiPart response. The reason I'm suspecting this issue is 
because the problem that I found is that during the switch from Ansi to 
Unicode strings (i.e. 2007 -> 2009), the logic to process the MIME parts was 
incorrectly done... It's not easy to *see* the problem because the bug in 
the Sender was cancelled by another bug in the receiving logic. However, 
once you interact with a non-Delphi framework passing MIME around, the 
problem shows up.


> I'm using delphi2010 and source files SOAPHTTPTrans.pas and RIO.pas seems 
> not distributed in source code.

This surprises me but maybe that's the case. I thought we always provided 
the source for the SOAP runtime. If you don't find the SOAP sources, I'd be 
happy to make them available. Could you grab the files I've posted here:

  https://forums.embarcadero.com/thread.jspa?messageID=332155&tstart=0#332155

And add them to your project. The key files to add are probably 
SOAPAttach.pas, SOAPHTTPTrans.pas and RIO.pas (but you may add more/all). 
Once, that's done, rebuild the project. The bug that I ran into while 
looking at the other thread mentioned above was related to the ReadContent 
method in SOAPAttach.pas (around line 616). The version you have probably 
reads:

{code}
  procedure ReadContent(ADestStream: TStream);
  var
    SLine: String;
  begin
    SLine := UTF8ToString(ReadLine(MimeStream.SourceStream));
    while (MimeStream.SourceStream.Position <= MimeStream.SourceStream.Size) 
and
          (not SameMimeBoundary(SLine, MimeBoundary)) do
    begin
      ADestStream.Write(SLine[1], Length(SLine));
      SLine := UTF8ToString(ReadLine(MimeStream.SourceStream));
      if Length(SLine) = 0 then
        Raise Exception.Create(SMimeReadError);
    end;
    FLastMimeBoundary := sLine;
  end;
{code}

And that's wrong because SLine is a 'string' which means we will be writing 
double-byte characters into the stream. The correct version would be:

{code}
  procedure ReadContent(ADestStream: TStream);
  var
    SLine: AnsiString;
  begin
    SLine := ReadLine(MimeStream.SourceStream);
    while (MimeStream.SourceStream.Position <= MimeStream.SourceStream.Size) 
and
          (not SameMimeBoundary(SLine, MimeBoundary)) do
    begin
      ADestStream.Write(SLine[1], Length(SLine));
      SLine := ReadLine(MimeStream.SourceStream);
      if Length(SLine) = 0 then
        Raise Exception.Create(SMimeReadError);
    end;
    FLastMimeBoundary := sLine;
  end;
{code}

IOW, SLine should be an AnsiString.

Try the above and let me know if any of that is relevant to your case. Thank 
you.

Cheers,

Bruneau
0
Jean
3/19/2011 5:01:26 AM
> {quote:title=Jean-Marie Babet wrote:}{quote}
> Hello,
> 
> 
> > However, I've tried to write code using Delphi 2007.
> >
> > Incredibly, with Delphi 2007 it works perfectly!! The parser  returns the 
> > correct answers.
> 
> Ummm... this makes me suspect that you might be running in the SOAPAttach 
> problem I noticed recently and mentioned here:
> 
>   https://forums.embarcadero.com/message.jspa?messageID=328727#328727
> 
> In that particular case, the problem was a Delphi Service not properly 
> handling a MultiPart request but it's the same code that's used by a Client 
> to handle a MultiPart response. The reason I'm suspecting this issue is 
> because the problem that I found is that during the switch from Ansi to 
> Unicode strings (i.e. 2007 -> 2009), the logic to process the MIME parts was 
> incorrectly done... It's not easy to *see* the problem because the bug in 
> the Sender was cancelled by another bug in the receiving logic. However, 
> once you interact with a non-Delphi framework passing MIME around, the 
> problem shows up.
> 
> 
> > I'm using delphi2010 and source files SOAPHTTPTrans.pas and RIO.pas seems 
> > not distributed in source code.
> 
> This surprises me but maybe that's the case. I thought we always provided 
> the source for the SOAP runtime. If you don't find the SOAP sources, I'd be 
> happy to make them available. Could you grab the files I've posted here:
> 
>   https://forums.embarcadero.com/thread.jspa?messageID=332155&tstart=0#332155
> 
> And add them to your project. The key files to add are probably 
> SOAPAttach.pas, SOAPHTTPTrans.pas and RIO.pas (but you may add more/all). 
> Once, that's done, rebuild the project. The bug that I ran into while 
> looking at the other thread mentioned above was related to the ReadContent 
> method in SOAPAttach.pas (around line 616). The version you have probably 
> reads:
> 
> {code}
>   procedure ReadContent(ADestStream: TStream);
>   var
>     SLine: String;
>   begin
>     SLine := UTF8ToString(ReadLine(MimeStream.SourceStream));
>     while (MimeStream.SourceStream.Position <= MimeStream.SourceStream.Size) 
> and
>           (not SameMimeBoundary(SLine, MimeBoundary)) do
>     begin
>       ADestStream.Write(SLine[1], Length(SLine));
>       SLine := UTF8ToString(ReadLine(MimeStream.SourceStream));
>       if Length(SLine) = 0 then
>         Raise Exception.Create(SMimeReadError);
>     end;
>     FLastMimeBoundary := sLine;
>   end;
> {code}
> 
> And that's wrong because SLine is a 'string' which means we will be writing 
> double-byte characters into the stream. The correct version would be:
> 
> {code}
>   procedure ReadContent(ADestStream: TStream);
>   var
>     SLine: AnsiString;
>   begin
>     SLine := ReadLine(MimeStream.SourceStream);
>     while (MimeStream.SourceStream.Position <= MimeStream.SourceStream.Size) 
> and
>           (not SameMimeBoundary(SLine, MimeBoundary)) do
>     begin
>       ADestStream.Write(SLine[1], Length(SLine));
>       SLine := ReadLine(MimeStream.SourceStream);
>       if Length(SLine) = 0 then
>         Raise Exception.Create(SMimeReadError);
>     end;
>     FLastMimeBoundary := sLine;
>   end;
> {code}
> 
> IOW, SLine should be an AnsiString.
> 
> Try the above and let me know if any of that is relevant to your case. Thank 
> you.
> 
> Cheers,
> 
> Bruneau

Hello, 
the web server has been down these days so I could not do the tests. 
Howevere now It's  back on line.
 
Thanks for the sources. 

 
The procedure ReadContent (ADestStream: TStream); is never called. 

I've noticed this differences:

In THTTPReqResp.Send(const ASrc: TStream): Integer;

the value of the variabile  ContentHeader differs: 

delphi 2007:
        "Content type: text/xml; Charset ="utf-8";
delphi 2010:
         "Content type: application+soap/xml; Charset ="utf-8"; action="urn:getContrattoFull"

But the real problem is  in the unit SOAPAttach.pas in funtcion  GetMimeBoundaryFromType(const ContentType: string): string; 
where ContentType passed is wrong.

In delphi 2007 it has: ContentType 'multipart/related; boundary=MIMEBoundaryurn_uuid_9686357FA57BD537381301077406041; type="text/xml"; start="<0.urn:uuid:9686357FA57BD537381301077406042@apache.org>"'
In delphi 2010 non sense character.

Cheers
Bruno
0
Bruno
3/25/2011 6:31:18 PM
Hi Bruno,

did you get your programm to work? I think I've got the same problem here. I got an response as multipart, but the variable FContentType doesn't contain a valid content-type. It only contains hieroglyphics.

Best regards

Robin
0
Robin
10/7/2011 11:27:13 AM
Hello,
i using THttpRIO component in Delphi 2010 (Rad studio 2010 version 14.0.3615.26342) for a web service client application.

My WSDL Location is:
https://ws-telematicoprova.agenziadogane.it/TelematicoFtpEjbHttpRouter/TelematicoFtpWsBindingImplService/META-INF/wsdl/TelematicoFtp.wsdl

I put these setting for Thttprio component:

WSDLLocation=https://ws-telematicoprova.agenziadogane.it/TelematicoFtpEjbHttpRouter/TelematicoFtpWsBindingImplService/META-INF/wsdl/TelematicoFtp.wsdl
Port=TelematicoFtpWsBindingImpl (automatically obtained in design time)
Service=TelematicoFtpWsBindingImplService (automatically obtained in design time)
HTTPWebNode.UserName=XXXXXX
HTTPWebNode.Password=YYYYYY

i generated code with WSDL Importer with these settings:

WSDL Source:
https://ws-telematicoprova.agenziadogane.it/TelematicoFtpEjbHttpRouter/TelematicoFtpWsBindingImplService/META-INF/wsdl/TelematicoFtp.wsdl
User Name: XXXXXX
Password: YYYYYY
Proxy: [blank]
Automatic SOAP Versioning. (Recommended)
Other: as default

It seems to connect in a right way, but As soon as i call one of the functions i have the same exception:

EDOMParseError  "Invalid at the top level of document Line: 1 --MIMEBoundaryurn_uuid_847C5CE04B841C7BA"

I get this httprio component response in OnAfterExecute event:

------------------------------------------------------------------------------------------------------
--MIMEBoundaryurn_uuid_847C5CE04B841C7BA01339434035856
Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:847C5CE04B841C7BA01339434035857@apache.org>

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault><faultcode>soapenv:Server</faultcode>
<faultstring>java.lang.NullPointerException</faultstring>
</soapenv:Fault></soapenv:Body></soapenv:Envelope>
--MIMEBoundaryurn_uuid_847C5CE04B841C7BA01339434035856--
------------------------------------------------------------------------------------------------------

i generated again code with WSDL Importer with same settings but changing the option:

- Process only WSDL Binding extensions for the SOAP 1.1 Protocol

instead of

-Automatic SOAP Versioning. (Recommended)

and had the same exception.

Finally i generated again code with WSDL Importer with same settings but changing the option:

- Process only WSDL Binding extensions for the SOAP 1.2 Protocol

and in this case i had another  exception:

ESOAPHTTPException 
"Unable to retrieve the URL endpoint for Service/Port 'TelematicoFtpWsBindingImplService/TelematicoFtpWsBindingImpl' 
from WSDL https://ws-telematicoprova.agenziadogane.it/TelematicoFtpEjbHttpRouter/TelematicoFtpWsBindingImplService/META-INF/wsdl/TelematicoFtp.wsdl"


I tested the web service with same setting with SoapUI 4.5.0 and is running ok.
I tested the application whit another web service and it running ok

please help me 

cheers
Enzo Rubino
0
Enzo
6/11/2012 6:00:43 PM
Do you have found a solution?
I have Delphi XE2 and the same problem.

Thank you
Alessandro
0
Alessandro
10/4/2012 4:02:50 PM
Reply: