我自己的 SOAP 代码?
D6 教授
我们必须使用 SOAP XML 服务。 我尝试导入wsdl,并使用Delphi生成的界面,但失败。
而且:正如我所见,我必须在 XML 部分中提供用户名和密码,但我不知道如何使用此自动界面...
我确定我手动提供 XML。 这不是问题,问题是如何发布到服务器...... wsdl import 知道如何调用服务器。它知道网址、端口等。
我想编写自己的代码。我认为 SOAP 调用是使用“Post”方法,我可以轻松做到这一点。 但是post需要什么参数呢? SOAP服务器读取哪些参数?
要理解我所说的内容,请参阅此代码(FParams : TStrings):
procedure TDDHTTPObject.Post;
var
WinHttpReq : variant;
posts : string;
begin
Result := '';
WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
try
posts := EncodeParamsToURL(FParams);
URL := URL + '?' + posts;
WinHttpReq.Open('POST', URL, false);
WinHttpReq.Send();
Result := WinHttpReq.ResponseText;
finally
WinHttpReq := 0;
end;
end;
例如:
Params['data'] = xmlstring;
或
Params['soap'] = xmlstring;
你知道一些关于它的事情吗?
D6 prof.
We must use a SOAP XML service.
I tried to import wsdl, and use the interface generated by Delphi, but it is failed.
And: as I see I must provide username and password in an XML section, but I don't know how to do with this automatic interface...
I determined that I provide the XML by hand.
It is not problem, the problem is how to post into server...
The wsdl import knows how to call the server. It is know the url, port, etc.
I want to write my own code. As I think SOAP calls are uses "Post" method what I can do easily.
But what parameter is needed for post?
Which parameters is what read by SOAP server?
To understand what I talking about it, see this code (FParams : TStrings):
procedure TDDHTTPObject.Post;
var
WinHttpReq : variant;
posts : string;
begin
Result := '';
WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
try
posts := EncodeParamsToURL(FParams);
URL := URL + '?' + posts;
WinHttpReq.Open('POST', URL, false);
WinHttpReq.Send();
Result := WinHttpReq.ResponseText;
finally
WinHttpReq := 0;
end;
end;
For example:
Params['data'] = xmlstring;
or
Params['soap'] = xmlstring;
Do you know something about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用 .NET 作为 Web 服务器,当您浏览到 WS URL 时,您可以看到方法和原始 XML,即:
http://yourdomain.com/ws/ApplicationWebService.asmx
XML 可用于 SOAP 1.1和1.2
它可能看起来像这样(SOAP 1.1):
接下来我使用“MSXML2.XMLHTTP”,如下所示:
If you use .NET as your web server you can see the Methods and raw XML when you browse to the WS URL ie:
http://yourdomain.com/ws/ApplicationWebService.asmx
the XML is available for both SOAP 1.1 and 1.2
and it may look like this (SOAP 1.1):
Next I use "MSXML2.XMLHTTP" like this:
实例化您自己的 THttpRio 组件并将其传递给 Web 服务调用。使用 THttpRio.BeforeExecute 事件在将 SOAPRequest 流发送到服务之前对其进行修改。那里有很多例子,但看看 THttprio onBeforeExecute 更改soapRequest作为一个可以帮助你的例子去。
Instantiate your own THttpRio component and pass it in to the web service call. Use the THttpRio.BeforeExecute event to modify the SOAPRequest stream before it gets sent to the service. Lots of examples out there but look at THttprio onBeforeExecute changing the soapRequest as one to get you going.