Проблема веб-службы Coldfusion - PullRequest
0 голосов
/ 13 июня 2011

У меня следующий вызов веб-службы:

    <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> 

Это вызывает следующий веб-сервис:

<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. 

Я троллю гугл и проследил за обычными подозреваемыми для такого рода ошибок, но пока безрезультатно.

Любая помощь чрезвычайно ценится.

Ответы [ 2 ]

2 голосов
/ 13 июня 2011

При вызове через веб-сервис вам может потребоваться передать все аргументы, доступные в функции, но в случае, если вы хотите передать его как необязательный, вы должны указать ColdFusion, что он пропускается, просто добавив атрибуты omit = "true" Смотри ниже

   <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#">
    <cfinvokeargument name="sMerchant" value="" omit="true">
    <cfinvokeargument name="sBuylineUser" value="" omit="true">
   </cfinvoke> 
0 голосов
/ 13 июня 2011

Я помню время, когда я создавал Web-сервисы, когда бы я не изменял базовый код, заглушка не создавалась снова, хотя в java.Таким образом, вызываемый вами веб-сервис не будет обновляться на стороне сервера.Это было действительно странно.Даже при том, что я вставлял refreshWSDL = true, изменения не распознаются.Вы можете попробовать перезагрузить сервер cf.Это может помочь.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...