help for SOAP client and attachment with delphi 7

Hi,
I'm very newbie with SOAP and I hope you can help me for a probably very easy question that I cannot resolve.
I have to send an attachment (JPG, PDF or PNG) to a SOAP server (that I cannot modify because it's created from another organization).
I only have istructions for an XML like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:data="http://www.xxxxxx.it/Data">
<soapenv:Header />
<soapenv:Body>
<data:uploadImage>
<header>
<data:username></data:username>
<data:password></data:password>
</header>
<image>
<data:filename></data:filename>
<data:filedata></data:filedata>
</image>
</data:uploadImage>
</soapenv:Body>
</soapenv:Envelope>

filedata is the attachment ID (something like cid:9999999999) Content-ID reference multipart/related.
Now I always used RTC (real thin client) library to work with this server when no attachment was needed, but now I don't know how to do to find attachment Content-ID and to send MIME type. 
I've tried to use Pocketsoap library and with that I can send the attachment but it seems (?) that I can't personalize the rest of my XML layout.
I hope I've been clear and sorry for newbie questions and the bad english :P
Hope you can help me.

Thanks.
0
Gello
3/18/2014 9:25:56 AM
embarcadero.delphi.webservices 976 articles. 0 followers. Follow

3 Replies
724 Views

Similar Articles

[PageSpeed] 57

Gello Mari wrote:
> Hi,
> I'm very newbie with SOAP and I hope you can help me for a probably very easy question that I cannot resolve.
> I have to send an attachment (JPG, PDF or PNG) to a SOAP server (that I cannot modify because it's created from another organization).
> I only have istructions for an XML like this:
>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:data="http://www.xxxxxx.it/Data">
> <soapenv:Header />
> <soapenv:Body>
> <data:uploadImage>
> <header>
> <data:username></data:username>
> <data:password></data:password>
> </header>
> <image>
> <data:filename></data:filename>
> <data:filedata></data:filedata>
> </image>
> </data:uploadImage>
> </soapenv:Body>
> </soapenv:Envelope>
>
> filedata is the attachment ID (something like cid:9999999999) Content-ID reference multipart/related.
> Now I always used RTC (real thin client) library to work with this server when no attachment was needed, but now I don't know how to do to find attachment Content-ID and to send MIME type.
> I've tried to use Pocketsoap library and with that I can send the attachment but it seems (?) that I can't personalize the rest of my XML layout.
> I hope I've been clear and sorry for newbie questions and the bad english :P
> Hope you can help me.
>
> Thanks.
>

I use the Indy components to send multipart data with something like this:


function PostVIAIndy( <parameters as needed> ): Boolean;
var
   IdHTTP: TIdHTTP;
   IdSSLIOHandlerSocket: TIdSSLIOHandlerSocketOpenSSL;
   tmpMPFDS: TIdMultiPartFormDataStream;
   tmpResult, URI: String;
begin
   Result := False;

   URI := GetMyCustomerURI;
   if URI = '' then
     Exit;

   tmpMPFDS:= TIdMultiPartFormDataStream.Create;
   IdHTTP := TIdHTTP.Create( nil );
   try
     tmpMPFDS.AddFormField( 'Name', 'value' );
     tmpMPFDS.AddFile( 'FileName', FileString, 'application/octet-stream' );

     if Pos( 'HTTPS://', UpperCase(URI) ) = 1 then
     begin
       IdSSLIOHandlerSocket := TIdSSLIOHandlerSocketOpenSSL.Create( nil );
       IdSSLIOHandlerSocket.SSLOptions.Method := sslvSSLv23;
       IdHTTP.IOHandler := IdSSLIOHandlerSocket;
     end;

     IdHTTP.HandleRedirects         := True;
     IdHTTP.Request.ContentType     := 'multipart/form-data';
     IdHTTP.Request.ContentLength   := Length( FileString );
     IdHTTP.Request.UserAgent       := 'ME';
     IdHTTP.Request.Connection      := 'close';
     IdHTTP.Request.Pragma          := 'no-cache';
     IdHTTP.AllowCookies := False;
     IdHTTP.HTTPOptions := [];

     try
       tmpResult := IdHTTP.Post( URI, tmpMPFDS );
     except on E:Exception do
       tmpResult := ''; // Indy raises exceptions for anything like a 
401 unauthorized, etc.
     end;
     if tmpResult <> '' then
       Result := True;
   finally
     FreeAndNil( IdHTTP );
     FreeAndNil( IdSSLIOHandlerSocket );
     FreeAndNil( tmpMPFDS );
   end;
end;
0
daniel
3/24/2014 8:34:24 PM
> {quote:title=daniel raith wrote:}{quote}
> Gello Mari wrote:
> > Hi,
> > I'm very newbie with SOAP and I hope you can help me for a probably very easy question that I cannot resolve.
> > I have to send an attachment (JPG, PDF or PNG) to a SOAP server (that I cannot modify because it's created from another organization).
> > I only have istructions for an XML like this:
> >
> > <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> > xmlns:data="http://www.xxxxxx.it/Data">
> > <soapenv:Header />
> > <soapenv:Body>
> > <data:uploadImage>
> > <header>
> > <data:username></data:username>
> > <data:password></data:password>
> > </header>
> > <image>
> > <data:filename></data:filename>
> > <data:filedata></data:filedata>
> > </image>
> > </data:uploadImage>
> > </soapenv:Body>
> > </soapenv:Envelope>
> >
> > filedata is the attachment ID (something like cid:9999999999) Content-ID reference multipart/related.
> > Now I always used RTC (real thin client) library to work with this server when no attachment was needed, but now I don't know how to do to find attachment Content-ID and to send MIME type.
> > I've tried to use Pocketsoap library and with that I can send the attachment but it seems (?) that I can't personalize the rest of my XML layout.
> > I hope I've been clear and sorry for newbie questions and the bad english :P
> > Hope you can help me.
> >
> > Thanks.
> >
> 
> I use the Indy components to send multipart data with something like this:
> 
> 
> function PostVIAIndy( <parameters as needed> ): Boolean;
> var
>    IdHTTP: TIdHTTP;
>    IdSSLIOHandlerSocket: TIdSSLIOHandlerSocketOpenSSL;
>    tmpMPFDS: TIdMultiPartFormDataStream;
>    tmpResult, URI: String;
> begin
>    Result := False;
> 
>    URI := GetMyCustomerURI;
>    if URI = '' then
>      Exit;
> 
>    tmpMPFDS:= TIdMultiPartFormDataStream.Create;
>    IdHTTP := TIdHTTP.Create( nil );
>    try
>      tmpMPFDS.AddFormField( 'Name', 'value' );
>      tmpMPFDS.AddFile( 'FileName', FileString, 'application/octet-stream' );
> 
>      if Pos( 'HTTPS://', UpperCase(URI) ) = 1 then
>      begin
>        IdSSLIOHandlerSocket := TIdSSLIOHandlerSocketOpenSSL.Create( nil );
>        IdSSLIOHandlerSocket.SSLOptions.Method := sslvSSLv23;
>        IdHTTP.IOHandler := IdSSLIOHandlerSocket;
>      end;
> 
>      IdHTTP.HandleRedirects         := True;
>      IdHTTP.Request.ContentType     := 'multipart/form-data';
>      IdHTTP.Request.ContentLength   := Length( FileString );
>      IdHTTP.Request.UserAgent       := 'ME';
>      IdHTTP.Request.Connection      := 'close';
>      IdHTTP.Request.Pragma          := 'no-cache';
>      IdHTTP.AllowCookies := False;
>      IdHTTP.HTTPOptions := [];
> 
>      try
>        tmpResult := IdHTTP.Post( URI, tmpMPFDS );
>      except on E:Exception do
>        tmpResult := ''; // Indy raises exceptions for anything like a 
> 401 unauthorized, etc.
>      end;
>      if tmpResult <> '' then
>        Result := True;
>    finally
>      FreeAndNil( IdHTTP );
>      FreeAndNil( IdSSLIOHandlerSocket );
>      FreeAndNil( tmpMPFDS );
>    end;
> end;

Hi daniel,
thank you very much for your reply.
In your code where is the zone in which I can define my XML code?

Thanks. Sorry for the newbieism.
0
Gello
3/29/2014 4:54:41 PM
anyone?
0
Gello
4/8/2014 3:08:54 PM
Reply: