我有一个 WCF 服务端点。该服务配置为 WCF 服务,其中安全模式 = TransportWithMessageCredential 和消息安全 clientCredentialType 设置为用户名,使用 CustomValidator 进行用户名/密码验证。
我在 ac# Console Application 中有这段代码(有效):
ServiceClient client = new ServiceClient();
client.ClientCredentials.UserName.UserName = "myusername";
client.ClientCredentials.UserName.Password = "mypassword";
Console.WriteLine(client.GetVersion());
上面的代码有效 - 使用 cfinvoke 的 ColdFusion 等价物是什么?我目前有以下(在用户名/密码介绍之前工作正常)
<cfinvoke
webservice="#wsurl#"
method="getVersion"
returnvariable="gcversion"
refreshwsdl="true">
</cfinvoke>
包含“客户凭证”的合适位置在哪里?
编辑:似乎该服务正在使用“WS-Security”。我正在努力寻找有关 CF2016 对 WS-Security 的支持的信息。这似乎是一个标准,所以我不确定为什么很难找到信息。
如果有人可以提供任何资源,我将不胜感激。
EDIT2:我正在尝试这样做:``` ws = CreateObject("webservice", wsurl, {refreshwsdl=true});
objSoapHeader = XmlParse("<wsse:Security mustUnderstand=""false"" xmlns:wsse=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd""><wsse:UsernameToken><wsse:Username>myun</wsse:Username><wsse:Password>mypass</wsse:Password></wsse:UsernameToken></wsse:Security>");
addSOAPRequestHeader(ws, "ignoredNameSpace", "ignoredName", objSoapHeader,false);
version =ws.getVersion();
writeOutput(version);
但我收到以下错误:
Cannot perform web service invocation getVersion.
The fault returned when invoking the web service operation is:
org.apache.axis2.AxisFault: Must Understand check failed for header http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd : Security
at org.apache.axis2.engine.AxisEngine.checkMustUnderstand(AxisEngine.java:105)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:171)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:364)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at cwtgift.CWTGiftServiceStub.getVersion(CWTGiftServiceStub.java:1954)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
The error occurred in C:/ColdFusion2016/cfusion/wwwroot/test/getVersion.cfm: line 19
17 : addSOAPRequestHeader(ws, "ignoredNameSpace", "ignoredName", objSoapHeader,false);
18 :
19 : version =ws.getVersion();
20 : writeOutput(version);
21 : </cfscript>