WSDL-通过WS-Security身份验证使用Web服务-Delphi [英] WSDL - consume web service with WS-Security authentication - Delphi

查看:68
本文介绍了WSDL-通过WS-Security身份验证使用Web服务-Delphi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个电子发票项目,该项目使用WSDL Soap的下一个链接连接到服务

I'm doing a project for electronic invoicing, which connects to a service using WSDL Soap next link Link Wsdl Service

因此,我使用Delphi的 WSDL Importer 生成要连接的类.

So I use the WSDL Importer of Delphi to generate classes to connect.

我使用该服务的代码

procedure TForm1.Button1Click(Sender: TObject);
var
  tBillServ : billService;
  tSendB    : sendBill;
  ByteA     : TByteDynArray;
  tSendBResp: sendBillResponse;
begin
  tSendB:=sendBill.Create;
  tSendBResp:=sendBillResponse.Create;
  tSendB.fileName:='Demo.zip';
  SetLength(ByteA,2);
  ByteA[0]:=10;
  ByteA[1]:=20;
  tSendB.contentFile:=ByteA;
  tSendBResp:=tBillServ.sendBill(tSendB);
end;

我提交的数据仅是用于服务器响应的试用版,但出现了一条错误消息,一直在寻找,但找不到任何可以帮助我的信息.

The data that I submit are just trial for a response from the server but me an error message appears, was looking for but could not find anything that can help me.

如果需要WS-Security连接来更改由WSDL Importer生成的类的编程,那么

If a WS-Security connection is necessary to change the programming of the classes that are generated with the WSDL Importer?

我很麻烦,因为他们找不到解决它的方法.

I'm in big trouble, because they can not find a track to get to fix it.

希望我能帮助您,对不起我的英语,我使用google翻译器

I hope I can help, and sorry for my English, I use google translator

推荐答案

上周我遇到了同样的问题.我正在使用Delphi 2010.

I had the same problem last week. I'm using Delphi 2010.

首先:我无法实现功能齐全的TSOAPHeader后代.我可以达到的最远距离是在标头节点中获取"wsse:"前缀,还是使wsse命名空间正确声明.但是它们是互斥的:(.

First : I couldn't manage to implement a fully-functional TSOAPHeader descendant. The farthest I could reach was to either get the "wsse:" prefix in header nodes or making the wsse namespace properly declared. But they were mutually exclusive :(.

当您尝试调用Webservice方法时,我敢打赌您会收到以下消息:无WS-Security标头".是吗?

I could bet you got the following message when your tried to call your webservice method : "No WS-Security header". Right ?

添加WS-Security标头的实际工作方式是构建完整的标头节点,并在OnBeforeExecute()中添加以下代码:

The actual WORKING way to add a WS-Security header is to build the complete header node and add the following code in OnBeforeExecute() :

// Load a copy of the XML in a separate TXMLDocument
XMLDocument.LoadFromStream(SOAPRequest);<br> 
{ Build your complete proper WS-Security header node here)<br>
// Insert the header<br>
XMLDocument.DocumentElement.ChildNodes.Insert(0, SoapHeader);<br>
// THIS LINE IS MANDATORY, AS WE WISH TO OVERWITE THE REQUEST, NOT APPEND TO IT !!!<br>
SOAPRequest.Seek(0, soFromBeginning);<br>
// Overwrite the request<br>
XMLDocument.SaveToStream(SOAPRequest);

然后释放您的XMLDocument,进行清理等……应该可以.

And then, free your XMLDocument, do the clean-up, etc... It should work.

这篇关于WSDL-通过WS-Security身份验证使用Web服务-Delphi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆