【发布时间】:2015-09-04 07:35:34
【问题描述】:
对不起,这很长。我是 Java Web 服务的新手,并且一直在浏览 Web 上的示例,以创建一个 Java 客户端到由供应商应用程序托管的一对 WCF 服务。我可以分别为每个客户端创建客户端,但是当我尝试将它们放在一起时,第二个服务绑定会覆盖第一个。我很确定是 ObjectFactory 类被覆盖了。
我正在使用 Metro(未安装在 Eclipse 中)和以下 ant 构建在 exclipse 中。
build.xml:
<project default="wsimport">
<target name="wsimport">
<exec executable="C:/Metro/bin/wsimport.bat">
<arg line="-keep -s ../src -d ../bin -extension -Xnocompile -XadditionalHeaders -b ../build/wcf.jaxb -B-XautoNameResolution http://my.host.name/ptsqamt/Maintain/services/reports/2010/09/ReportServices.svc?singleWSDL"/>
</exec>
<exec executable="C:/Metro/bin/wsimport.bat">
<arg line="-keep -s ../src -d ../bin -extension -Xnocompile -XadditionalHeaders -b ../build/wcf.jaxb -B-XautoNameResolution http://my.host.name/ptsqamt/Maintain/services/reports/2010/09/ReportFileService.svc?singleWSDL"/>
</exec>
</target>
</project>
连接到 ReportFileService 有效,但是当我连接到 ReportServices 服务时,出现以下异常:
线程“主”javax.xml.ws.WebServiceException 中的异常: {http://tempuri.org/}ReportServices 不是有效的服务。有效的 服务是:{http://tempuri.org/}ReportFileService
我曾尝试将构建放在单独的包中,这可行,但我在运行时遇到了类似的问题。
我查看了各种线程,要么将目标名称空间从 http://tempuri.org/ 更改为其他名称,要么将 ObjectFactory 类名称更改为自定义名称。
我有这个内联代码(找到here),但我不知道如何使用它/将其更改为外部文件。
<xsd:complexType name="ObjectFactory">
<xsd:annotation>
<xsd:appinfo>
<jxb:class name="ReportServicesObjectFactory" />
</xsd:appinfo>
</xsd:annotation>
</xsd:complexType>
谁能帮我解决这个问题。
【问题讨论】:
标签: java xml web-services jaxb