Delphi calls Java's WebService upload XML file (xe10.2+win764)

Source: Internet
Author: User

Related information:
1.http://blog.csdn.net/luojianfeng/article/details/51219890
2.http://blog.csdn.net/avsuper/article/details/8764165

Precautions:

1. When generating a WSDL file, the D7 may not be generated, and the XE version can be used to generate it all.

return byte stream:

1   functionGetByte (astring:string): Tbytedynarray;2   var3 Sbyte:tbytedynarray;4   begin5 SetLength (SByte, Length (astring));6Move (astring[1], sbyte[0], Length (astring));7Result: =SByte;8   End;
View Code

Instance code: Delphi Tbytedynarray (Bytes) to Java WebService Save

1 procedureTform1.btn17click (sender:tobject);2 var3 Strm:tmemorystream;4 Afiledata:tbytedynarray;5 Fsize:integer;6 begin7STRM: = Tmemorystream.Create;8Img1. Picture.Graphic.SaveToStream (STRM);//turn a picture into a memory stream9Strm. position:=0;//Remember, you must do this before you manipulate the picture, otherwise the errorTen     //Convert the memory stream into Tbytedynarray Onefsize:=STRM. Size; A SetLength (afiledata,fsize); -Strm. Read (afiledata[0],fsize); -addresult:=Servicehello1.adduser_byte (EDT4. Text, afiledata); the   if(addresult='OK') Then -   begin -ShowMessage ('Add Success'); -   End; + End;
View Code

Example code: How to upload Files via WebService in Delphi, compare

1 varFileNamestring;2X:string;3 Mstream:tmemorystream;4C:Array  ofTbytedynarray;5 begin6HTTPRIO1. httpwebnode.useutf8inheader:=true;7HTTPRIO1. wsdllocation:='Http://localhost/grsb/pswService.asmx';8HTTPRIO1. service:='Pswservice';9HTTPRIO1. port:='Pswservicesoap';TenHttpdeclare:=httprio1 asPswservicesoap; One   AMstream: = Tmemorystream.Create; -   Try -   ifOpendialog1.execute Then the   begin -filename:=Opendialog1.filename; - mstream.loadfromfile (filename); -Mstream.position: =0; + SetLength (c, mstream.size); -Mstream.readbuffer (c[0], mstream.size); +X:=httpdeclare.zluploadfile (c[0]); A   //showmessage (x); at   End; -   finally - Mstream.free; -   End; - End;
View Code

Instance code: Delphi calls the Java WebService upload XML file

1 procedureTform1.button2click (sender:tobject);2 Const3SName ='name';4Spassword ='Pass';5Sdatetime ='2017-11-12 19:41:00';6SCode ='610101';7SCode2 ='060611882';8 var9 Irtjsserviceporttype:rtjsserviceporttype;Ten st:string; One Sinfo:tbytedynarray; A P:pchar; -Sstring; - Ostream:tmemorystream; the begin -   //Memory Flow Method -OStream: = Tmemorystream.Create; -   Try +     begin -Ostream.loadfromfile ('Aaa.xml'); +Ostream.position: =0; A SetLength (Sinfo, ostream.size); at //Mstream.readbuffer (sinfo[0], mstream.size); -Ostream.read (sinfo[0], ostream.size); -Irtjsserviceporttype: =Getrtjsserviceporttype; -S: =Irtjsserviceporttype.uploadinpregister (SName, Spassword, Sdatetime, SCode, SCode2, sinfo); - ShowMessage (s); -     End; in   finally - Ostream.free; to   End; + End;
View Code

Delphi calls Java's WebService upload XML file (xe10.2+win764)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.