简体   繁体   English

使用 JAX-WS 在 WebLogic 中没有模式导入的单个 WSDL

[英]Single WSDL with no schema imports in WebLogic with JAX-WS

How can I configure a web service generated by WebLogic 10.3.6 using JAX-WS to include the object schema inside one single WSDL file declaration, instead of an import declaration?如何使用 JAX-WS 配置由 WebLogic 10.3.6 生成的 Web 服务,以将对象模式包含在单个 WSDL 文件声明中,而不是导入声明中?

Example code:示例代码:

Interface界面

import javax.ejb.Local;

@Local
public interface CustomerBeanLocal {

    public void updateCustomer(Customer customer);

}

Session Bean会话 Bean

import javax.ejb.Stateless;
import javax.jws.WebService;

@Stateless
@WebService
public class CustomerBean implements CustomerBeanLocal {

    @Override
    public void updateCustomer(Customer customer) {
        // Do stuff...
    }   

}

WSDL Generated WSDL 生成

We need the schema definitions not be imported with the <xsd:import> tag in the example below, but to be declared inside the WSDL, which means all contract information is in a single WSDL file.我们需要在下面的示例中不使用<xsd:import>标记导入模式定义,而是在 WSDL 中声明,这意味着所有合同信息都在单个 WSDL 文件中。 No dependencies of other files.没有其他文件的依赖关系。

<!-- ... -->

<types>
  <xsd:schema>
  <xsd:import namespace="http://mybeans/" schemaLocation="http://192.168.10.1:7001/CustomerBean/CustomerBeanService?xsd=1" /> 
  </xsd:schema>
</types>

<!-- ... -->

The same code with WildFly includes the schema types inside the WSDL, and do not use the import feature.与 WildFly 相同的代码包括 WSDL 中的模式类型,并且不使用导入功能。 After some research I didn't find a way to configure the bean/server to do it in WebLogic (didn't find JAX-WS or WebLogic proprietary features to do it).经过一番研究,我没有找到一种方法来配置 bean/服务器以在 WebLogic 中执行此操作(没有找到 JAX-WS 或 WebLogic 专有功能来执行此操作)。

I understand the benefits of having an exported schema (reusability, etc) but it is a requirement of the project that the types must be declared inside of the WSDL, not imported.我了解拥有导出模式(可重用性等)的好处,但项目要求必须在 WSDL 内部声明类型,而不是导入。

Do you use the provided wsgen-tool for the wsdl-generation?您是否将提供的 wsgen-tool 用于 wsdl-generation? If yes, there is a parameter called:如果是,则有一个参数称为:

-inlineSchemas

which exactly does what you want.这正是你想要的。

"Used to inline schemas in a generated wsdl. Must be used in conjunction with the -wsdl option. " (Source: https://jax-ws.java.net/nonav/2.2.1/docs/wsgen.html ) “用于在生成的 wsdl 中内联模式。必须与 -wsdl 选项结合使用。” (来源: https ://jax-ws.java.net/nonav/2.2.1/docs/wsgen.html)

You can automate wsgen with the jaxws-maven-plugin .您可以使用jaxws-maven-plugin自动化 wsgen。 The latest version of the plugin uses jaxws 2.2 but if you specify target 2.1, the generated artifacts will be compatible with your platform.最新版本的插件使用 jaxws 2.2,但如果您指定target 2.1,生成的工件将与您的平台兼容。

<plugin>
    <groupId>org.jvnet.jax-ws-commons</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <version>2.3</version>
    <executions>
      <execution>
        <id>wsgen</id>
        <phase>process-classes</phase>
        <goals>
          <goal>wsgen</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <sei>...put your WS impl class here...</sei>
      <keep>true</keep>
      <verbose>true</verbose>
      <target>2.1</target>
      <genWsdl>true</genWsdl>
      <xnocompile>true</xnocompile>
      <inlineSchemas>true</inlineSchemas>
    </configuration>
  </plugin>

Package the generated WSDL file in your war file (by default under WEB-INF/wsdl) and then add wsdlLocation to your annotation.将生成的 WSDL 文件打包到您的 war 文件中(默认在 WEB-INF/wsdl 下),然后将 wsdlLocation 添加到您的注释中。

@WebService(wsdlLocation = 'MyService.wsdl')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM