0

私はWebサービスを構築しようとしています。文字列を返す単純な Web サービスのコードを次に示します。最初に、 ben nadelからいくつかのコードを挿入し ました。そうしないと、パラメーターを渡すときにエラーが発生するため、スタブファイルが自動的に更新されます。

<cfcomponent 
    displayname="BaseWebService"
    output = "false"
    hint="This handles core web service features">


    <cffunction
        name="Init"
        access="public"
        returntype="any"
        output="false"
        hint="Returns an initialized web service instance.">

        <cfreturn THIS />
    </cffunction>

    <cffunction
        name="RebuildStubFile"
        access="remote"
        returntype="void"
        output="false"
        hint="Rebuilds the WSDL file at the given url.">

        <cfargument name="Password" type="string" required="true" default="" />

        <cfif NOT Compare(ARGUMENTS.Password, "sweetlegs!")>
            <cfset CreateObject("java", "coldfusion.server.ServiceFactory"
                    ).XmlRpcService.RefreshWebService(
                        GetPageContext().GetRequest().GetRequestUrl().Append("?wsdl").ToString()) />
        </cfif>

        <cfreturn />
    </cffunction>

    <cffunction 
        name="easyService"
        access="remote"
        returntype="any"
        output="false">

        <cfargument name="anyOutput" type="string" default="this and that" />
        <cfargument name="xtype" type="string" required="yes" default="1" />        

            <cfif Compare(xtype, "1") EQ 0>
                <cfset anyVar = "one" />
            <cfelse>
                <cfset anyVar = "two" />

            </cfif>
        <cfreturn anyVar>       
    </cffunction>
</cfcomponent>

ここでは、Web サービスを呼び出そうとしています。

<cfinvoke
    webservice="https://[...]/Components/Webservice.cfc?wsdl"
    method="RebuildStubFile">

    <cfinvokeargument 
        name="Password" 
        value="sweetlegs!" />
</cfinvoke>
<cfinvoke
    webservice="[...]/Components/Webservice.cfc?wsdl"
    method="easyService"
    returnVariable="anyVar" >

    <cfinvokeargument
        name="xtype"
        value="2" 
        omit="true">
</cfinvoke>

<cfdump var="#anyVar#">

Web サービス コンポーネントの最初のメソッドは呼び出すことができますが、2 番目のメソッドは常に次のエラー メッセージを返します。

coldfusion.xml.rpc.ServiceProxy$ServiceMethodNotFoundException: Web service operation     easyService with parameters {xtype={2}} cannot be found.
    at coldfusion.xml.rpc.ServiceProxy.invoke(ServiceProxy.java:149)
    at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2301)
    at coldfusion.tagext.lang.InvokeTag.doEndTag(InvokeTag.java:454)

WebサービスのURLを入力すると、追加して

?method=easyService&xtype=2

正しい値を返します。しかし、これは GET メソッドで値を渡すようなものです。

私は何時間も探していましたが、どこで問題が発生したのかわかりません。

4

1 に答える 1

3

WebService呼び出しを使用するときは、すべての引数を指定し、適切な引数(xtypeではなく)でomit="true"を使用する必要があると思います。

<cfinvoke
    webservice="[...]/Components/Webservice.cfc?wsdl"
    method="easyService"
    returnVariable="anyVar" >

    <cfinvokeargument
        name="anyOutput"
        value=""
        omit="true">

    <cfinvokeargument
        name="xtype"
        value="2">
</cfinvoke>
于 2012-05-03T11:17:41.613 に答える