使用 ColdFusion webservice - 找不到带有参数 {} 的 Web 服务操作 [英] Consuming ColdFusion webservice - Web service operation with parameters {} cannot be found

查看:14
本文介绍了使用 ColdFusion webservice - 找不到带有参数 {} 的 Web 服务操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试使用网络服务,但出现错误.

I am testing consuming a web-service and I'm getting an error.

这是网络服务组件:

<cfcomponent >
<cffunction name="listBooks" access="remote" returntype="string" output="no" >

    <cfquery name="getBooks" datasource="cfbookclub" >
        SELECT bookID, title, bookDescription, genre
        FROM books
        ORDER BY title desc
    </cfquery>

    <cfsavecontent variable="bookList" >
        <books>
            <cfoutput query="getBooks" >
            <book id="#getBooks.bookID#" >
                <title>#XMLFormat( getBooks.title )#</title>
                <description>#XMLFormat( getBooks.bookDescription )#</description>
                <genre>#XMLFormat( getBooks.genre )#</genre>
            </book>
            </cfoutput>
        </books>
    </cfsavecontent>

    <cfreturn bookList >
</cffunction>

这是消费页面:

<cfinvoke 
webservice="http://127.0.0.1/books.cfc?wsdl"
method="listBooks"
returnvariable="rawXMLBookList" >
</cfinvoke>

看起来很简单——当我收到初始错误时,我实际上是在尝试传递一个参数流派",

Seems simple enough - I was actually trying to pass an argument "genre" when I got the initial error,

Web service parameter name category cannot be found in the provided parameters {genre}.

所以我删除了所有对参数的引用,但仍然出现此错误

So I removed all reference to arguments, and STILL get this error

Web service operation with parameters {} cannot be found. 

这个错误听起来像是找不到网络服务,但是如果我将网址剪切并粘贴到浏览器中,我会得到预期的 XML 文档...

The error makes it sound like the web-service cannot be found, however if I cut and paste the url into my browser I get the expected XML doc...

这个网站上有另一个类似的帖子,但问题是base64问题,我只是返回txt所以我不认为这是一个类似的问题,即使错误消息是相似的.

There was another post like this on this site, but the problem was a base64 issue, I'm just returning txt so I don't think it's a similar problem, even through the error msg is similar.

推荐答案

尝试将 refreshWSDL 参数添加到您的 <cfinvoke> 调用中,看看是否有帮助.

Try adding the refreshWSDL argument to your <cfinvoke> call and see if that helps.

<cfinvoke 
    webservice="http://127.0.0.1/books.cfc?wsdl"
    method="listBooks"
    refreshwsdl="yes"
    returnvariable="rawXMLBookList"> 
</cfinvoke>

设置 refreshwsdl="yes" 会重新加载 WSDL 文件并重新生成用于使用 Web 服务的工件.

Setting refreshwsdl="yes" reloads the WSDL file and regenerates the artifacts used to consume the web service.

请注意,您不想为所有请求保留此设置.您只需为刷新工件的一个请求设置它.然后你应该把它改回 refreshwsdl="no".直到你再次需要它.

Note you do not want to keep this setting for all of your requests. You just need to set it for one request to refresh the artifacts. Then you should change it back to refreshwsdl="no". Until you need it again.

这是 Charlie Arehart 的博客的摘录 关于 refreshWSDL 参数:

Here is an excerpt from Charlie Arehart's Blog about the refreshWSDL argument:

为什么必须刷新网络服务元数据?

暂时备份一下,问题源于 CF 试图提供帮助.在对给定 Web 服务的第一次请求时,CF 会进行一些缓存以使未来的请求更快,而不是缓存 Web 服务方法的结果,而是缓存 CF 根据 Web 服务本身的描述使用的工件.

Just to back up for a moment, the problem stems from CF's attempt to help. On the first request for a given web service, CF does some caching to make future requests go faster, not caching the results of the web service method but rather the artifacts used by CF based on the description of the web service itself.

CF 使用第一次调用时报告的 Web 服务描述 (WSDL) 来创建基于此的 java 代理/存根,然后在 CF 到该 Web 服务的未来调用中重复使用.

CF uses the web service description (WSDL) reported at the time of that first call to create a java proxy/stub based on that, which it then reuses on future calls from CF to that web service.

如果/当 Web 服务元数据发生更改时,就会出现问题.CF 不会知道,并且会继续使用旧的缓存代理/存根,如果它与 Web 服务返回的新 WSDL 不匹配,您的长时间运行的代码可能会失败.

The issue arises if/when the web service metadata changes. CF won't know, and will continue to use the older cached proxy/stub, and your long-running code may fail if it doesn't match the new WSDL returned by the web service.

所以我们需要一种方法来告诉 CF 刷新它的代理存根缓存.

So we need a way to tell CF to refresh its cache of that proxy stub.

这项新功能无疑是实现这一目标的最简单方法,但并不是唯一的方法.

This new feature is certainly the easiest way to make that happen, but it's not the only way.

这篇关于使用 ColdFusion webservice - 找不到带有参数 {} 的 Web 服务操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆