上次提問的帖子
https://bbs.csdn.net/topics/392395664
——————————————————————
hj8090:
按照你說的改了,有了回傳值,但不管發送什么字串回傳都是一樣的({"obj":"003"})
但我用測驗工具發送{"token":"14123ss23sf3oodhgl38403","msgType":"10001","msgBody":{"manifestNo":"20180923004","plateNumber":"晉AB0322","driverName":"張無忌","driverIdentityCardNo":"132305198907050043"}} 回傳值為( {"obj":"004"} )
測驗工具資訊如下:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<process xmlns="http://api.weighbridge.internet.shencai.com/">
<arg0 xmlns="">{"token":"14123ss23sf3oodhgl38403","msgType":"10001","msgBody":{"manifestNo":"20180923004","plateNumber":"晉AB0322","driverName":"張無忌","driverIdentityCardNo":"132305198907050043"}}</arg0>
</process>
</soap:Body>
</soap:Envelope>
——————————————————————————
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:processResponse xmlns:ns2="http://api.weighbridge.internet.shencai.com/">
<return>{"obj":"004"}</return>
</ns2:processResponse>
</soap:Body>
</soap:Envelope>
uj5u.com熱心網友回復:
客戶端代碼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;
哪里出現問題了呢?
uj5u.com熱心網友回復:
重新再delphi2010中做了客戶端,回傳值都是{"obj":"003"},懷疑是客戶端接收為null造成,因為發送有效字符還是無效字符都回傳{"obj":"003"},回傳代碼標識格式錯誤。用測驗工具發送有效字串回傳{"obj":"004"}。
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
uj5u.com熱心網友回復:
用RestClient做了個測驗,發現msgType值不同,回傳 json obj 的值也不同,介面呼叫應該是正常,你應該先獲取到webservice各類回傳值對應含義。再檢查引數是否有正確。在不知道引數有效值以及回傳代碼含義情況下,等于瞎子摸象。
比如:msgType="1000" <return>{"obj":"003"}</return>
msgType="1001" <return>{"obj":"004"}</return>
uj5u.com熱心網友回復:
不要用delphi 做web了 看了就頭疼.....php java go python 那個做web不比delphi 強
前兩天用delphi的idhttp調做好的介面都有問題
post資料中 "+"號 在java后臺那里被urldecode為空格
死活找不到原因
最后idhttp換系統原生的IXMLHTTPRequest 搞定
uj5u.com熱心網友回復:
Delphi Web 就是問題不少。uj5u.com熱心網友回復:
1如果服務端是你自己的,可以比較下Delphi發送的引數和其他語言發送的引數有什么區別?2用高版本的Delphi重新匯入這個wsdl,我只有XE3,匯入沒有成功。
3用C#測驗是{"obj":"004"}
uj5u.com熱心網友回復:
看來的是delphi的問題了,服務端不是自己的,沒法。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/41300.html
標籤:網絡通信/分布式開發
上一篇:請推薦遠程桌面控制組件
下一篇:新人報道!
