Single WSDL with no schema imports in WebLogic with JAX-WS
Asked Answered
M

2

8

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?

Example code:

Interface

import javax.ejb.Local;

@Local
public interface CustomerBeanLocal {

    public void updateCustomer(Customer customer);

}

Session 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

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. 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. 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).

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.

Mikimikihisa answered 4/12, 2014 at 12:14 Comment(2)
This is a pretty good answer to a similar question: #16031074Vallo
I am saving manual intervention as a last resource. There should be a way to configure it (even with a non portable feature). If manual edition is the only alternative for WebLogic, then I'll probably go for contract-first generation.Mikimikihisa
B
3

Do you use the provided wsgen-tool for the 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)

Bantling answered 8/1, 2015 at 9:59 Comment(2)
I get my WSDL from the URL after the deployment of JAX-B and JAX-WS annotated POJOs in the server, adding the "?WSDL" text after the full service URL. The WSDL is generated at runtime. Do you know any way I can tell the runtime to generate the inline schemas? I will look into your suggestion too as soon as I can (weekend).Mikimikihisa
Checking the generated WSDL file by WebLogic I can see that it uses the WSGEN 2.1.5 (there is a comment inside the file). Since the -inlineSchemas switch was introduced by the 2.2.1 release, the conclusion is that WebLogic at version 10.3.6 is not able to do it. I will generate the WSDLs outside the container using a recent version of WSGEN. Thank you.Mikimikihisa
C
2

You can automate wsgen with the jaxws-maven-plugin. 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.

<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.

@WebService(wsdlLocation = 'MyService.wsdl')
Caponize answered 6/4, 2016 at 10:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.