Delphi XE 无法正确使用 WebService
让 WSDL 显示在 Delphi XE 下面正在创建如下所示的代码。 Out WebService 正在 BizTalk 服务器上运行:
....
....
PicassoBTSTest_PortalOrchestration_Port_Portal = interface(IInvokable)
['{706CEB1F-0EC1-08C2-03C7-395C12905558}']
**procedure Operation_Portal(var part: Variant); stdcall;**
end;
function GetPicassoBTSTest_PortalOrchestration_Port_Portal(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): PicassoBTSTest_PortalOrchestration_Port_Portal;
....
....
当调用 WebService 时,我正在执行如下所示的操作:
procedure TForm1.Button2Click(Sender: TObject);
var
X: PicassoBTSTest_PortalOrchestration_Port_Portal;
V: Variant;
begin
X := GetPicassoBTSTest_PortalOrchestration_Port_Portal;
V := 'JUST A TEST';
X.Operation_Portal(V);
ShowMessage(V);
end;
正如我们在日志中看到的,此代码正在正确调用我们的后端。但我们没有收到正确的回复。调用Operation_Portal后,V参数没有变化。当它应该包含其他值时,它包含“JUST A TEST”文本。
我尝试运行 Delphi 2006 中的代码,它给出了相同的结果。
我做错了什么。为什么我没有收到后端的响应?
/布莱恩
<?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:tns="http://techotel.dk/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://techotel.dk/" name="BizTalkServiceInstance">-<wsdl:documentation><CreationInfo Created="2012-01-26 10:31:43Z"/></wsdl:documentation>-<wsdl:types><xsd:schema targetNamespace="http://techotel.dk/Imports"/></wsdl:types>-<wsdl:message name="PicassoBTSTest_PortalOrchestration_Port_Portal_Operation_Portal_InputMessage"><wsdl:part name="part" type="xsd:anyType"/></wsdl:message>-<wsdl:message name="PicassoBTSTest_PortalOrchestration_Port_Portal_Operation_Portal_OutputMessage"><wsdl:part name="part" type="xsd:anyType"/></wsdl:message>-<wsdl:portType name="PicassoBTSTest_PortalOrchestration_Port_Portal"><wsdl:documentation>service "PicassoBTSTest.PortalOrchestration" port "Port_Portal"</wsdl:documentation>-<wsdl:operation name="Operation_Portal"><wsdl:documentation>operation "Operation_Portal"</wsdl:documentation><wsdl:input message="tns:PicassoBTSTest_PortalOrchestration_Port_Portal_Operation_Portal_InputMessage"/><wsdl:output message="tns:PicassoBTSTest_PortalOrchestration_Port_Portal_Operation_Portal_OutputMessage"/></wsdl:operation></wsdl:portType>-<wsdl:binding name="BasicHttpBinding_ITwoWayAsync" type="tns:PicassoBTSTest_PortalOrchestration_Port_Portal"><soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>-<wsdl:operation name="Operation_Portal"><wsdl:documentation>operation "Operation_Portal"</wsdl:documentation><soap:operation style="document" soapAction="Operation_Portal"/>-<wsdl:input><soap:body use="literal"/></wsdl:input>-<wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding>-<wsdl:service name="BizTalkServiceInstance">-<wsdl:port name="BasicHttpBinding_ITwoWayAsync" binding="tns:BasicHttpBinding_ITwoWayAsync"><soap:address location="http://akibiztalk01.internal.local/PicassoBTSTestPortal/PicassoBTSTest_PortalOrchestration_Port_Portal.svc"/></wsdl:port></wsdl:service></wsdl:definitions>
Having the WSDL show below Delphi XE is creating the code as show here. Out WebService is running on a BizTalk server:
....
....
PicassoBTSTest_PortalOrchestration_Port_Portal = interface(IInvokable)
['{706CEB1F-0EC1-08C2-03C7-395C12905558}']
**procedure Operation_Portal(var part: Variant); stdcall;**
end;
function GetPicassoBTSTest_PortalOrchestration_Port_Portal(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): PicassoBTSTest_PortalOrchestration_Port_Portal;
....
....
When calling the WebService I'm doing as shown here:
procedure TForm1.Button2Click(Sender: TObject);
var
X: PicassoBTSTest_PortalOrchestration_Port_Portal;
V: Variant;
begin
X := GetPicassoBTSTest_PortalOrchestration_Port_Portal;
V := 'JUST A TEST';
X.Operation_Portal(V);
ShowMessage(V);
end;
As we can see in our logs this code is calling our back end correct. But we do not receive the correct response back. The V parameter is unchanged after we call the Operation_Portal. It contains the 'JUST A TEST' text when it should contain an other values.
I've tried running the code from Delphi 2006 and it gives me the same result.
What am I doing wrong. Why doesn't I receive the response from our back end?
/Brian
<?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:tns="http://techotel.dk/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://techotel.dk/" name="BizTalkServiceInstance">-<wsdl:documentation><CreationInfo Created="2012-01-26 10:31:43Z"/></wsdl:documentation>-<wsdl:types><xsd:schema targetNamespace="http://techotel.dk/Imports"/></wsdl:types>-<wsdl:message name="PicassoBTSTest_PortalOrchestration_Port_Portal_Operation_Portal_InputMessage"><wsdl:part name="part" type="xsd:anyType"/></wsdl:message>-<wsdl:message name="PicassoBTSTest_PortalOrchestration_Port_Portal_Operation_Portal_OutputMessage"><wsdl:part name="part" type="xsd:anyType"/></wsdl:message>-<wsdl:portType name="PicassoBTSTest_PortalOrchestration_Port_Portal"><wsdl:documentation>service "PicassoBTSTest.PortalOrchestration" port "Port_Portal"</wsdl:documentation>-<wsdl:operation name="Operation_Portal"><wsdl:documentation>operation "Operation_Portal"</wsdl:documentation><wsdl:input message="tns:PicassoBTSTest_PortalOrchestration_Port_Portal_Operation_Portal_InputMessage"/><wsdl:output message="tns:PicassoBTSTest_PortalOrchestration_Port_Portal_Operation_Portal_OutputMessage"/></wsdl:operation></wsdl:portType>-<wsdl:binding name="BasicHttpBinding_ITwoWayAsync" type="tns:PicassoBTSTest_PortalOrchestration_Port_Portal"><soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>-<wsdl:operation name="Operation_Portal"><wsdl:documentation>operation "Operation_Portal"</wsdl:documentation><soap:operation style="document" soapAction="Operation_Portal"/>-<wsdl:input><soap:body use="literal"/></wsdl:input>-<wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding>-<wsdl:service name="BizTalkServiceInstance">-<wsdl:port name="BasicHttpBinding_ITwoWayAsync" binding="tns:BasicHttpBinding_ITwoWayAsync"><soap:address location="http://akibiztalk01.internal.local/PicassoBTSTestPortal/PicassoBTSTest_PortalOrchestration_Port_Portal.svc"/></wsdl:port></wsdl:service></wsdl:definitions>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我将验证服务器是否发送回包含预期值的 XML SOAP 响应。
如果该值在响应中,则 Delphi 会以某种方式无法将其分配给 Variant 变量。
该服务是用 C# 开发的吗?也许对于测试而言,编写 Delphi 版本的服务并比较响应 XML 结构会有所帮助。
First I would verify that the server sends a XML SOAP response back which contains the expected value.
If the value is in the response, then Delphi somehow fails to assign it to the Variant variable.
Has the service been developed in C#? Maybe for tests it is helpful to write a Delphi version of the service and compare the response XML structure.