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

查看:209
本文介绍了在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抛出的本地实例错误,该方法不能找到,并显示我已经通过的字段的原始列表(em'ed上面)。我需要与方法参数一一比较,找出我错过了什么。



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

解决方案

最后,我完成了编写额外的代码,以帮助我测试我的服务。此外,我需要向我的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天全站免登陆