1,593
社区成员
发帖
与我相关
我的任务
分享
SolidWasteService单元,delphi生成。
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://211.90.38.54:18282/WebService/SolidWasteService?wsdl
// >Import : http://211.90.38.54:18282/WebService/SolidWasteService?wsdl=ISolidWasteService.wsdl
// >Import : http://211.90.38.54:18282/WebService/SolidWasteService?wsdl=ISolidWasteService.wsdl>0
// Encoding : UTF-8
// Version : 1.0
// (2018-06-11 20:09:19 - - $Rev: 25127 $)
// ************************************************************************ //
unit SolidWasteService;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
const
IS_OPTN = $0001;
IS_UNQL = $0008;
type
// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Embarcadero types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"[Gbl]
// ************************************************************************ //
// Namespace : http://api.weighbridge.internet.shencai.com/
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : SolidWasteServiceImplServiceSoapBinding
// service : SolidWasteServiceImplService
// port : SolidWasteServiceImplPort
// URL : http://211.90.38.54:18282/WebService/SolidWasteService
// ************************************************************************ //
ISolidWasteService = interface(IInvokable)
['{4C6FB50E-23F9-5664-0A8D-F79439A6E7E1}']
function process(const arg0: string): string; stdcall;
end;
function GetISolidWasteService(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): ISolidWasteService;
implementation
uses SysUtils;
function GetISolidWasteService(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ISolidWasteService;
const
defWSDL = 'http://211.90.38.54:18282/WebService/SolidWasteService?wsdl';
defURL = 'http://211.90.38.54:18282/WebService/SolidWasteService';
defSvc = 'SolidWasteServiceImplService';
defPrt = 'SolidWasteServiceImplPort';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as ISolidWasteService);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(ISolidWasteService), 'http://api.weighbridge.internet.shencai.com/', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ISolidWasteService), '');
InvRegistry.RegisterInvokeOptions(TypeInfo(ISolidWasteService), ioDocument);
//InvRegistry.RegisterInvokeOptions(TypeInfo(ISolidWasteService), ioLiteral);
end.
客户端代码
unit weight;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, InvokeRegistry, Rio, SOAPHTTPClient, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
HTTPRIO1: THTTPRIO;
Memo2: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses SolidWasteService;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
tmp_p: String;
tmp_r :string;
begin
tmp_p:='{"token":"14123s","msgType":"10001","msgBody":{"manifestNo":"201804","plateNumber":"晋AB322","driverName":"张","driverIdentityCardNo":"132305198907050043"}}';
tmp_r:=GetISolidWasteService(false,'',nil).process(tmp_p);
Memo2.Lines.Text:=tmp_r;
end;
end.
用测试工具测试'{"token":"14123s","msgType":"10001","msgBody":{"manifestNo":"201804","plateNumber":"晋AB322","driverName":"张","driverIdentityCardNo":"132305198907050043"}}';返回值为{"obj":"004"}
表单
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 443
ClientWidth = 606
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 240
Top = 128
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object Memo2: TMemo
Left = 288
Top = 288
Width = 185
Height = 89
ImeName = #20013#25991'('#31616#20307') - '#25628#29399#25340#38899#36755#20837#27861
Lines.Strings = (
'Memo2')
TabOrder = 1
end
object HTTPRIO1: THTTPRIO
URL = 'http://211.90.38.54:18282/WebService/SolidWasteService?wsdl'
HTTPWebNode.UseUTF8InHeader = True
HTTPWebNode.InvokeOptions = [soIgnoreInvalidCerts, soAutoCheckAccessPointViaUDDI]
HTTPWebNode.WebNodeOptions = []
Converter.Options = [soSendMultiRefObj, soTryAllSchema, soRootRefNodesToBody, soCacheMimeResponse, soUTF8EncodeXML]
Left = 216
Top = 224
end
end
比如:msgType="1000" <return>{"obj":"003"}</return>
msgType="1001" <return>{"obj":"004"}</return>
procedure TForm1.Button3Click(Sender: TObject);
var
tmp_p: process;
tmp_r :Widestring;
begin
//HTTPRIO1.HTTPWebNode.UseUTF8InHeader :=True;
tmp_p:=process.Create ;
//tmp_r:=processResponse.Create;
tmp_p.arg0:=WidestringToString(Memo1.Lines.Text);
tmp_r:=GetSolidWasteService(False,'',HTTPRIO1).process(tmp_p);
//Memo2.Lines.Text:=tmp_r.return;
Memo2.Lines.Text:=(tmp_r) ;
end;
哪里出现问题了呢?