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

2nc8po8w  于 2022-11-15  发布在  其他
关注(0)|答案(2)|浏览(161)

如何配置WebLogic 10.3.6使用JAX-WS生成的Web Service,以便在单个WSDL文件声明(而不是导入声明)中包含对象Schema?
示例代码:

界面

import javax.ejb.Local;

@Local
public interface CustomerBeanLocal {

    public void updateCustomer(Customer customer);

}

会话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

我们不需要在下面的例子中用<xsd:import>标记导入模式定义,而是在WSDL中声明模式定义,这意味着所有的合约信息都在一个WSDL文件中,不依赖于其他文件。

<!-- ... -->

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

<!-- ... -->

与WildFly相同的代码包括WSDL内部的模式类型,并且不使用导入功能。经过一些研究,我没有找到一种方法来配置bean/服务器在WebLogic中执行此操作(没有找到JAX-WS或WebLogic专有功能来执行此操作)。
我理解导出模式的好处(可重用性等),但项目要求类型必须在WSDL内部声明,而不是导入。

jfewjypa

jfewjypa1#

是否使用提供的wsgen-tool生成wsdl-generation?如果是,则有一个名为的参数:

-inlineSchemas

这正是你想要的。

  • “用于在生成的wsdl中内联架构。必须与-wsdl选项一起使用。“*(源:(第10页)
dwthyt8l

dwthyt8l2#

您可以使用jaxws-maven-plugin自动化wsgen。最新版本的插件使用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>

将生成的WSDL文件打包到war文件中(默认情况下在WEB-INF/wsdl下),然后将wsdlLocation添加到注解中。

@WebService(wsdlLocation = 'MyService.wsdl')

相关问题