在ColdFusion中获取可读的WSDL服务方法参数错误 [英] Get readable WSDL service method arguments error in ColdFusion

查看:156
本文介绍了在ColdFusion中获取可读的WSDL服务方法参数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < cfinvoke webservice =#ServiceURL#方法=AddCustomerreturnvariable =ResponseDataargumentcollection =#stAguments#> 
< cfinvokeargument name =api_keyvalue =#ServiceKey#/>
< / cfinvoke>显然,这个调用之前填写的

stAguments 结构。
想象一下,你忘了在这个容器中添加一个参数,或者使用错误的参数类型,比如说创建了无效的请求。 ColdFusion抛出异常,可以被捕获,但不能(不是字面上)被读取:

  * Web服务操作AddCustomer具有参数{ postcode = {12345},org_name = {Terms test 7.79661762856},fax = {},html = {1},addr1 = {address1},firstname = {sergey},city = {Austin},country = {} {},notify = {1},lastname = {galashyn},addr2 = {},ssn = {},api_key = {8FE9AD0BCF2382D92A1080DB3AA62DB9},taxrate = {0},terms = {Net 15},active = {} = {},salutation = {Mr。},password = {123},account_manager = {1}}无法找到。* 

它会一个个地手动检查所有这些参数。这是问题。



也许任何人都使用一些技巧来使这更容易。



我甚至想关于某种解析器来自动执行此比较。



感谢任何想法和想法。



谢谢。



PS对不起我的英语 - 不是我的母语。请问是否我写的不够清楚。



编辑:





问题仅在创建请求时填写方法参数容器时读取错误消息。



例如,方法有10个参数,我不小心添加了9个本地实例的CF throws错误,该方法无法找到,并显示了我已经通过的字段的原始列表(em'ed above)。我需要一个一个地用方法论比较他们,找到我错过的东西。



真的,这是一个可用性和时间节省问题。

解决方案

最后我完成了编写额外的代码来帮助我测试我的服务。此外,我需要为我的API用户提供CFML中的示例并组合这些任务。



想分享代码示例,也许有人会发现它们很有用。



我已经使用验证结构方法(但是通过删除正则表达式有点简化,因为在我的情况下它们是开销 - 服务验证传入的参数并报告错误)。主要思想是拉WSDL并构建结构模板来与测试数据进行比较。另外,添加简单的脚本与界面来测试不同的方法,它可以帮助我更快地测试服务变化。



所以,这里是用于获取WSDL和比较结构的UDF (我的XPath-fu可能不是一个完美的:),这里是基础测试代码



希望这种发布代码的方式不违规。

>

特别感谢 Tomalak 的想法。


I'm developing a service invoking script that looks like:

<cfinvoke webservice="#ServiceURL#" method="AddCustomer" returnvariable="ResponseData" argumentcollection="#stAguments#">
    <cfinvokeargument name="api_key" value="#ServiceKey#" />
</cfinvoke>

stAguments structure filled before this call, obviously. Imagine you've forgot to add one of arguments into this container or used wrong argument type, say created invalid request. ColdFusion throws exception that can be catched, but can not (not literally) be read:

*Web service operation AddCustomer with parameters {postcode={12345},org_name={Terms test 7.79661762856},fax={},html={1},addr1={address1},firstname={sergey},city={Austin},country={},taxable={},notify={1},lastname={galashyn},addr2={},ssn={},api_key={8FE9AD0BCF2382D92A1080DB3AA62DB9},taxrate={0},terms={Net 15},active={},state={},salutation={Mr.},password={123},account_manager={1}} cannot be found.*

It breaks my head checking all these arguments manually one by one. This is the problem.

Maybe anyone uses some technique to make this easier.

I've even thought about some kind of parser to automate this comparison.

Will appreciate any thought and ideas.

Thank you.

P.S. Sorry for my English -- not my native language. Please ask if I've wrote anything not clear enough.

EDIT:

To clarify. Problem is not in accessing service. I am owner of it and I am definitely know all arguments and their types of each method.

Problem is only in reading error message when creating request -- filling method arguments container.

For example, method got 10 arguments and accidentally I've added 9 -- local instance of CF throws error that method can't be found and shows raw list (em'ed above) of fields I've passed. And I need to compare them one by one with method arguments to find what I've missed.

Really, it's an usability and time saving problem.

解决方案

Finally I've finished with writing additional code to help me testing my service. Also, I needed to provide my API users with examples in CFML and combined these tasks.

Would like to share code samples, maybe someone else will find them useful.

I've used validating structures method (but a bit simplified it by removing regex'es because of they are overhead in my case -- service validates incoming arguments and reports errors). Main idea was to pull WSDL and build structure-template to compare with testing data. Also, added simple script with interface to test different methods, it helps me to test changes in service faster.

So, here is UDFs for fetching WSDL and comparing structures (my XPath-fu can be not a perfect :) and here is base testing code.

Hope this way of publishing code is not a rules violation. Thought it's not a good idea to post it all right here.

Special thanks to Tomalak for his ideas.

这篇关于在ColdFusion中获取可读的WSDL服务方法参数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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