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

查看:14
本文介绍了“重复的文件名"使用来自不同子域的 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?wsdlhttp://galashyn.ourwebsite.com/api/bsapi.cfc?wsdl

问题来了.

当第二个网站尝试注册 web-service 时,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.提示:您可能已经映射了两个具有相同元素的命名空间name 为相同的包名.它是建议您使用网络浏览器检索和检查请求的确保 WSDL 文档正确无误.如果请求的 WSDL 文档不能被检索或动态产生,很可能是目标 web 服务有编程错误.

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

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


当前解决方案

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

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

每个 CFC 都像这样扩展父级:

<cfcomponent output="false" extends="api.bsapi"><!--- 此组件用于扩展基本 api 版本 1.x ---></cfcomponent>

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

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


这是一个非常愚蠢的解决方法,但它现在有效.


其他解决方案是使用单个 API 子域并通过某些密钥识别客户(我们已经将它们用于安全目的),但由于一些遗留代码,它对我们有严重的负面问题.


请注意,我不懂 Java,所以很多具体的建议对我来说不是很清楚.

Google 显示这个问题存在多年,但我找不到聪明的解决方案.

所以也许在这里?

解决方案

<块引用>

我现在不能将 WSDL 放在所有客户的公共 URL 上",我已经解释了原因:因为我必须使用子域.如果您知道将 WSDL 放在一个 URL 并向另一个 URL 发出服务请求的方法——请告诉我.

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天全站免登陆