Coldfusion Web 服务问题
我有以下 Web 服务调用:
<cfinvoke webservice="#application.capsRemote#card.cfc?wsdl" method="purchase" returnVariable="retpurchase" refreshwsdl="true">
<cfinvokeargument name="iCustomer" value="#session.user.customerCode#">
<cfinvokeargument name="iAmountCents" value="#form.cc_amount*100#">
<cfinvokeargument name="sCard" value="#form.cc_number#">
<cfinvokeargument name="sExpiry" value="#form.cc_expiry#">
<cfinvokeargument name="sType" value="PAYMENT">
<cfinvokeargument name="sSecurityNo" value="#form.cc_securitycode#">
</cfinvoke>
这将调用以下 Web 服务:
<cffunction name="purchase" access="remote" returntype="struct" hint="This function wraps calls to the purchase method of the Buyline OCX at Compass">
<cfargument name="iCustomer" required="yes" type="string">
<cfargument name="iAmountCents" required="yes" type="string">
<cfargument name="sCard" required="yes" type="string">
<cfargument name="sExpiry" required="yes" type="string" hint="Format yyyymm">
<cfargument name="sType" required="yes" type="string">
<cfargument name="sSecurityNo" required="yes" type="string">
<cfargument name="sMerchant" required="no" default="F" type="string">
<cfargument name="sBuylineUser" required="no" default="FreenetWeb" type="string">
<cfscript>
var Status = "";
var StatusText = "";
var ResponseSequence = "";
var ResponseCode = "";
var ResponseText = "";
var stReturn = StructNew();
</cfscript>
<cftry>
<cfobject type="COM" action="Create" name="oBuyline" class="ctlBuyline.Buyline">
<cfscript>
// Create an instance of the OCX
oBuyline.Server = variables.sBuylineServer;
oBuyline.RemotePort = variables.nBuylineRemoteport;
oBuyline.UserName = variables.sBuylineUsername;
oBuyline.Password = variables.sBuylinePassword;
oBuyline.Timeout = variables.sBuylineTimeout;
</cfscript>
<cfscript>
// calling the purchase method, call does not contain the sSBank argument
Status = oBuyline.Purchase(arguments.sMerchant,arguments.iCustomer,arguments.iAmountCents,arguments.sCard,arguments.sExpiry,arguments.sBuylineUser,arguments.sType,0,arguments.sSecurityNo);
switch(Status)
{
case "0":
StatusText = oBuyline.ResponseText;
break;
case "1":
StatusText = "Successful transaction";
break;
case "2":
StatusText = oBuyline.ResponseText;
break;
default:
StatusText = "CAPS: Unknown issue with communicating with Buyline";
}
// response from the purchase method
ResponseSequence = oBuyline.Sequence;
ResponseCode = oBuyline.ResponseCode;
if (ResponseCode neq "0"){
ResponseText = "Declined (" & Replace(oBuyline.ResponseText, "ERROR~~", "") & ")";
} else {
ResponseText = "Approved";
}
// set return values
stReturn.Status = Status;
stReturn.StatusText = StatusText;
stReturn.ResponseSequence = ResponseSequence;
stReturn.ResponseCode = ResponseCode;
stReturn.ResponseText = ResponseText;
if (sMerchant eq "T") {
stReturn.MerchantId = "TEST555555";
} else {
stReturn.MerchantId = "1111111";
}
//
return stReturn;
</cfscript>
<cfcatch type="any"><!--- catch code ---></cfcatch>
</cftry>
但是,我收到以下错误:
Web service operation purchase with parameters {sSecurityNo={111},iAmountCents={100.0},sExpiry={201310},sCard={1111111111111111},iCustomer={111111},sType={PAYMENT}} cannot be found.
我已经在谷歌上搜索并跟踪了此类错误的常见嫌疑人,但到目前为止没有结果。
非常感谢任何帮助。
I have the following web service call:
<cfinvoke webservice="#application.capsRemote#card.cfc?wsdl" method="purchase" returnVariable="retpurchase" refreshwsdl="true">
<cfinvokeargument name="iCustomer" value="#session.user.customerCode#">
<cfinvokeargument name="iAmountCents" value="#form.cc_amount*100#">
<cfinvokeargument name="sCard" value="#form.cc_number#">
<cfinvokeargument name="sExpiry" value="#form.cc_expiry#">
<cfinvokeargument name="sType" value="PAYMENT">
<cfinvokeargument name="sSecurityNo" value="#form.cc_securitycode#">
</cfinvoke>
This calls the following web service:
<cffunction name="purchase" access="remote" returntype="struct" hint="This function wraps calls to the purchase method of the Buyline OCX at Compass">
<cfargument name="iCustomer" required="yes" type="string">
<cfargument name="iAmountCents" required="yes" type="string">
<cfargument name="sCard" required="yes" type="string">
<cfargument name="sExpiry" required="yes" type="string" hint="Format yyyymm">
<cfargument name="sType" required="yes" type="string">
<cfargument name="sSecurityNo" required="yes" type="string">
<cfargument name="sMerchant" required="no" default="F" type="string">
<cfargument name="sBuylineUser" required="no" default="FreenetWeb" type="string">
<cfscript>
var Status = "";
var StatusText = "";
var ResponseSequence = "";
var ResponseCode = "";
var ResponseText = "";
var stReturn = StructNew();
</cfscript>
<cftry>
<cfobject type="COM" action="Create" name="oBuyline" class="ctlBuyline.Buyline">
<cfscript>
// Create an instance of the OCX
oBuyline.Server = variables.sBuylineServer;
oBuyline.RemotePort = variables.nBuylineRemoteport;
oBuyline.UserName = variables.sBuylineUsername;
oBuyline.Password = variables.sBuylinePassword;
oBuyline.Timeout = variables.sBuylineTimeout;
</cfscript>
<cfscript>
// calling the purchase method, call does not contain the sSBank argument
Status = oBuyline.Purchase(arguments.sMerchant,arguments.iCustomer,arguments.iAmountCents,arguments.sCard,arguments.sExpiry,arguments.sBuylineUser,arguments.sType,0,arguments.sSecurityNo);
switch(Status)
{
case "0":
StatusText = oBuyline.ResponseText;
break;
case "1":
StatusText = "Successful transaction";
break;
case "2":
StatusText = oBuyline.ResponseText;
break;
default:
StatusText = "CAPS: Unknown issue with communicating with Buyline";
}
// response from the purchase method
ResponseSequence = oBuyline.Sequence;
ResponseCode = oBuyline.ResponseCode;
if (ResponseCode neq "0"){
ResponseText = "Declined (" & Replace(oBuyline.ResponseText, "ERROR~~", "") & ")";
} else {
ResponseText = "Approved";
}
// set return values
stReturn.Status = Status;
stReturn.StatusText = StatusText;
stReturn.ResponseSequence = ResponseSequence;
stReturn.ResponseCode = ResponseCode;
stReturn.ResponseText = ResponseText;
if (sMerchant eq "T") {
stReturn.MerchantId = "TEST555555";
} else {
stReturn.MerchantId = "1111111";
}
//
return stReturn;
</cfscript>
<cfcatch type="any"><!--- catch code ---></cfcatch>
</cftry>
However, I get the following error:
Web service operation purchase with parameters {sSecurityNo={111},iAmountCents={100.0},sExpiry={201310},sCard={1111111111111111},iCustomer={111111},sType={PAYMENT}} cannot be found.
I've trolled google and followed up the usual suspects for this type of error, to no avail so far.
Any help hugely appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过 Web 服务调用时,您可能需要传递函数中可用的所有参数,但如果您想作为可选参数传递,则需要告诉 ColdFusion 忽略它,只需添加属性 omit= "true"
见下文
While calling through webservice you may need to pass all arguments available in function but in case you want to pass as optional you need to tell ColdFusion to omit it just adding attributes omit= "true"
See below
我记得有一次,当我创建Web服务时,每当我更改底层代码时,都不会通过java再次创建存根。因此,被调用的 Web 服务实际上不会在服务器端刷新。真的很奇怪。即使我输入了refreshWSDL=true,它也无法识别更改。您可能想尝试重新启动 cf 服务器。这可能有帮助。
I remember a time when I was creating Web services, whenever I would change the underlying code, the stub would not be created again though java. So your web service being called would not actually refresh on the server side. It was really weird. Even though I was putting in refreshWSDL=true, it wouldn't recognize the change. You might want to try a restart of the cf server. That might help.