“重复文件名”对于从不同子域使用Web服务时的相同WSDL命名空间 [英] "Duplicate file name" for same WSDL namespace when using web-service from different sub-domains

查看:319
本文介绍了“重复文件名”对于从不同子域使用Web服务时的相同WSDL命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前言



我们正在为客户提供我们的服务API。



每个客户都有自己的子域(如sergii.ourwebsite.com)和自己的WSDL URL,它看起来像 http://sergii.ourwebsite.com/api/bsapi.cfc?wsdl



另外,使用相同代码库的所有网站(包括API)。






问题



说,同一CF服务器上的两个应用程序。这可能很容易发生,因为一些客户网站托管在我们的服务器上。



两者都试图使用自己的API WSDL,例如:

  http://sergii.ourwebsite.com/api/bsapi.cfc?wsdl 
http://galashyn.ourwebsite.com/api/bsapi。 cfc?wsdl

这里有问题。



当第二个网站尝试注册网络服务时,CF会抛出一个错误:


名称:
https://galashyn.ourwebsite.com/api/bsapi.cfc?wsdl
WSDL:
https://galashyn.ourwebsite.com/ api / bsapi.cfc?wsdl
org.apache.axis.wsdl.toJava.DuplicateFileException:
重复的文件名:
/opt/coldfusion8/stubs/WS1985941973/api/Bsapi.java。
提示:您可能将两个
命名空间映射到同一个
名称的元素到同一个包名。它是
建议您使用Web浏览器
检索和检查请求的
WSDL文档,以确保它是正确的。
如果请求的WSDL文档不能检索到
或者动态生成
,则很可能
目标Web服务编程
错误。

$问题是,他们都使用相同的WSDL命名空间,从CFC路径构建:



<$ p

$ p> < wsdl:definitions targetNamespace =http:// api>




当前解决方案



我们唯一可用的解决方案是使用CFC别名,例如:

  http://galashyn.ourwebsite.com/api/v1n1/bsapi.cfc?wsdl 
http://galashyn.ourwebsite.com/api/v1n1/bsapi.cfc ?wsdl

每个CFC扩展父类如下:

 < cfcomponent output =falseextends =api.bsapi> 
<!---这个组件用于扩展基本api版本1.x --->
< / cfcomponent>

它们产生不同的命名空间,可以毫无问题地使用 - 每个应用程序自己的命名空间: p>

 < wsdl:definitions targetNamespace =http://v1n1.api> 
< wsdl:definitions targetNamespace =http://v1n2.api>









其他解决方案是使用单个API子域,并通过一些键(我们已经使用它们用于安全目的)来识别客户,但是由于一些旧代码,我们有严重的负面问题。






请注意,我不知道Java,所以许多具体的建议对我来说都不太清楚。



Google显示此问题存在多年,但我找不到智能解决方案。



那么也许在这里?

解决方案

>

我现在不能将WSDL放置在所有客户的公共URL,我解释了为什么:因为我必须使用子域。如果您知道将WSDL放在一个网址并向其他网址发出服务请求的方式,请告诉我。



WSDL只是一个描述Web服务的XML文档。您可以使用CFML编写(自定义)。例如:



http://subdomain.domain.com/api/ wsdl.cfm?api = bsapi& customer = subdomain



只需复制由CF生成的WSDL,并将其用作自定义WSDL页面的模板。替换特定于子域​​的WSDL的部分,并返回XML文档。注意空格(可能请参阅 CFSilent CFSetting ),并考虑使用 CFHeader 将mime类型设置为text / xml。


Preface

We are providing customers with our service API.

Each customer has own subdomain (e.g. sergii.ourwebsite.com) and own WSDL URL, it looks like http://sergii.ourwebsite.com/api/bsapi.cfc?wsdl

Also, all the websites (including API, of course) using the same codebase.


Problem

Say, two applications on same CF-server. This can easily happen, because some of customer websites are hosted on our servers.

Both trying to use own API WSDL, say:

http://sergii.ourwebsite.com/api/bsapi.cfc?wsdl
http://galashyn.ourwebsite.com/api/bsapi.cfc?wsdl

And here come the problems.

When second website tries to register the web-service, CF throws an error:

Name: https://galashyn.ourwebsite.com/api/bsapi.cfc?wsdl. WSDL: https://galashyn.ourwebsite.com/api/bsapi.cfc?wsdl. org.apache.axis.wsdl.toJava.DuplicateFileException: Duplicate file name: /opt/coldfusion8/stubs/WS1985941973/api/Bsapi.java. Hint: you may have mapped two namespaces with elements of the same name to the same package name. It is recommended that you use a web browser to retrieve and examine the requested WSDL document to ensure it is correct. If the requested WSDL document cannot be retrieved or is dynamically generated, it is likely that the target web service has programming errors.

Problem is that both of them are using same WSDL namespace, built from CFC path:

<wsdl:definitions targetNamespace="http://api">


Current solution

The only working solution for us is using the CFC aliases, like:

http://galashyn.ourwebsite.com/api/v1n1/bsapi.cfc?wsdl
http://galashyn.ourwebsite.com/api/v1n1/bsapi.cfc?wsdl

Each this CFC extends the parent like this:

<cfcomponent output="false" extends="api.bsapi">
<!--- this component used to extend base api version 1.x --->
</cfcomponent>

They produce different namespaces, which can be used without problems -- own namespace for each application:

<wsdl:definitions targetNamespace="http://v1n1.api">
<wsdl:definitions targetNamespace="http://v1n2.api">


This is pretty dumb workaround, but it works for now.


Other solution would be to use the single API sub-domain and identifying the customers by some key (we are already using them for security purposes), but it has serious negative problems for us because of some legacy code.


Please note that I don't know Java, so many specific advices are not so clear for me.

Google shows that this problem exists for years, but I can't find the smart solution.

So maybe here?

解决方案

I can not "place the WSDL at a common URL for all customers" for now and I've explained why: because I have to use the sub-domains. If you know the way to put the WSDL at one URL and make service requests to another -- please tell me.

A WSDL is just an XML document that describes the web service. You can write (customize) it using CFML. For instance:

http://subdomain.domain.com/api/wsdl.cfm?api=bsapi&customer=subdomain

Then just copy the WSDL generated by CF, and use it as a template for your custom WSDL page. Replace the parts of the WSDL that are subdomain-specific and return the XML document. Be mindful of whitespace (perhaps see CFSilent, CFSetting), and consider using CFHeader to set the mime type to "text/xml".

这篇关于“重复文件名”对于从不同子域使用Web服务时的相同WSDL命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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