Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jaxb 我如何告诉wsimport单独的WSDL文件引用相同的对象类?_Jaxb_Jax Ws_Xjc_Wsimport - Fatal编程技术网

Jaxb 我如何告诉wsimport单独的WSDL文件引用相同的对象类?

Jaxb 我如何告诉wsimport单独的WSDL文件引用相同的对象类?,jaxb,jax-ws,xjc,wsimport,Jaxb,Jax Ws,Xjc,Wsimport,我有三个不同的JAX-WS服务,它们在服务器上使用相同的类(例如ServiceA、ServiceB、和ServiceC,它们都使用MyCommonClass作为参数)。我们正在开发的另一个模块是使用wsimport为这些服务创建客户机,但问题是wsimport为每个服务创建单独的MyCommonClass实例: com.company.servicea.endpoint.MyCommonClass com.company.serviceb.endpoint.MyCommonClass 等等

我有三个不同的JAX-WS服务,它们在服务器上使用相同的类(例如
ServiceA
ServiceB
、和
ServiceC
,它们都使用
MyCommonClass
作为参数)。我们正在开发的另一个模块是使用
wsimport
为这些服务创建客户机,但问题是wsimport为每个服务创建单独的
MyCommonClass
实例:

  • com.company.servicea.endpoint.MyCommonClass
  • com.company.serviceb.endpoint.MyCommonClass
  • 等等
我知道我可以使用
wsimport-p
选项为每个端点指定一个公共包,但是我希望将大多数类保留在单独的包中,而只是共享某些公共包。从我所读到的内容来看,JAXB绑定文件可能会有所帮助,但我还没有弄清楚实现所需结果的确切语法。我想每个服务都需要一个单独的绑定文件(我为每个服务调用一次wsimport),它看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb" version="2.1" xmlns:tns="http://endpoint.servicea.company.com/">
  <bindings node="//xsd:complexType[@name='myCommonClass']">
    <class name="com.company.model.MyCommonClass"/>
  </bindings>
</bindings>


我走对了吗?或者您是否有其他解决方案?

在xsd中定义您的公共类,并将其导入到服务WSDL中。 然后,使用模式定制将此模式中的定义生成到单独的包中,如“com.company.model”


参考:

<jxb:bindings
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
   version="1.0">
    <jxb:bindings schemaLocation="model.xsd" node="/xsd:schema">
        <jxb:schemaBindings>
        <jxb:package name="com.company.model"/>
        </jxb:schemaBindings>
</jxb:bindings>