使用cfscript和webservice对象发送SOAP调用

时间:2014-07-18 00:31:24

标签: web-services soap coldfusion

我正在尝试使用来自第三方的.NET soap API。我可以通过使用cfsavecontent和cfhttp来实现它,但我正在尝试使用Web服务对象。

如果我这样做

<cfsavecontent>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.myUrl.com/2005/">
   <soapenv:Header>
      <ns:AuthorizationToken>
         <!--Optional:-->
         <ns:Token>cb92b46a-9422-4483-a35a-345f51a6346b</ns:Token>
      </ns:AuthorizationToken>
   </soapenv:Header>
   <soapenv:Body>
      <ns:WebLogin>
         <ns:userLoginPlain>myUserName</ns:userLoginPlain>
         <ns:passwordPlain>myPassword</ns:passwordPlain>
         <!--Optional:-->
         <ns:keyOverride></ns:keyOverride>
      </ns:WebLogin>
   </soapenv:Body>
</soapenv:Envelope>
</cfsavecontent>

我可以让它工作,但如果我尝试

<cfscript>
    var rt = {};
    var ws = CreateObject("webservice", "Url");

     ws.Authenticate(userName=XWebUserId, password=XWebPassword);
     rt.AuthCall = xmlParse(GetSOAPResponse(ws));
     session.authToken = xmlSearch(rt.AuthCall,"//*[local-name()='Token']")[1].XmlText;

     addSOAPRequestHeader(ws, "http://www.myUrl.com/2005/", "token", session.authToken);
     ws.WebLogin(userLoginPlain='',passwordPlain='',keyOverride='');
     rt.soapresp = GetSOAPResponse(ws);
     return rt;
</cfscript>

我收到一条CF错误,上面写着Cannot perform web service invocation WebLogin.错误的详细信息如下:

The fault returned when invoking the web service operation is:
<pre>AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}
Client faultSubcode: faultString: System.Web.Services.Protocols.SoapException:
 Object reference not set to an instance of an object. at 
 myUrl.WebLogin(String userLoginPlain, String passwordPlain, String keyOverride)
 faultActor: https://ams.hftp.org/netForumHFTPTest/xweb/secure/netforumxml.asmx
 faultNode: faultDetail: {http://www.avectra.com/2005/}InvalidTokenException:
 <XWebException xmlns="http://www.avectra.com/2005/"><Message>Object reference 
  not set to an instance of an object.</Message><Number>0</Number>
  <Source>xWebClasses</Source><Line>0</Line><StackTrace> at 
 myUrl.ValidateToken(AuthorizationToken AuthToken) at 
 myuRL.netForum.xWeb.xWebSecure.xWebServiceClass.ValidateToken() at 
 myUrl.netForum.xWeb.xWebSecure.netForumXMLSecure.WebLogin(String userLoginPlain,    
 String passwordPlain, String keyOverride)</StackTrace><ErrorType>Ge... ''</pre> 

如果需要,我将通过cfsavecontent方法构建它,但是我希望有一种脚本方法可以做到这一点所以我不需要做很多不同的调用来制作脚本并且脚本少得多代码。

提前致谢

0 个答案:

没有答案
相关问题