Salesforce 中的 SOAP 安全性
我正在尝试更改当前如下所示的 Web 服务调用标头的 wsdl2apex 代码:
<代码>
<安全 xmlns="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd">
<用户名>test
<密码>测试
看起来像这样:
<代码>
一个问题是我无法弄清楚如何更改元素的名称空间(或者即使它们的名称很重要)。第二个问题是将 Type 属性放到 Password 元素上。
任何人都可以提供任何可能有帮助的信息吗?
谢谢
I am trying to change the wsdl2apex code for a web service call header that currently looks like this:
<env:Header>
<Security xmlns="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd">
<UsernameToken Id="UsernameToken-4">
<Username>test</Username>
<Password>test</Password>
</UsernameToken>
</Security>
</env:Header>
to look like this:
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-4" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>Test</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Test</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
One problem is that I can't work out how to change the namespaces for elements (or even if it matters what name they have). A secondary problem is putting the Type attribute onto the Password element.
Can any provide any information that might help?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也有类似的问题。我能够生成以下适用于我的实现的 SOAP 标头:
安全类:
将注释之间的行添加到 wsdl2apex 生成的类中:
I was having a similar issue. I was able to generate the following SOAP Header which worked for my implementation:
Security Class:
Add the lines between the comments to your class generated by wsdl2apex:
我有类似的问题。我手动创建了一个类来创建基本结构。幸运的是,我正在使用的服务要么假设要么能够确定类型是文本,而无需显式设置类型参数,因此您可能想尝试一下,看看它是否有效。
对于命名空间,我将它们设置为属性:
这个问题也可能有帮助:Salesforce WebServiceCallout.invoke 方法的参数是什么?
I had a similar problem. I manually created a class to create the basic structure. Fortunately, the service I was consuming either assumed or was able to determine that the type was text without the type parameter being explicitly set, so you may want to try that and see if it works.
For the namespaces I set those up as attributes:
This question may also be helpful: What are the parameters for the Salesforce WebServiceCallout.invoke method?
可能不是每个人都能做到,但我们通过使用 XSLT 将我们拥有的 SOAP 转换为我们想要的 SOAP 成功解决了这个问题。
Might not be possible for everyone, but we managed to solve the problem by using XSLT to transform the SOAP we had into the SOAP we wanted.