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)