J
J
JuliaJ5832014-01-31 18:22:05
Java
JuliaJ583, 2014-01-31 18:22:05

How to generate two clients from WSDLs in such a way that both clients have the same set of folders?

I have two services: Service_1 and Service_2:
First Service:

public class HelloWorldPublisherByServer1 {
  public static void main(String[] args) {
     Endpoint.publish("http://localhost:9999/ws/hello", new HelloWorldImplByService1());
    }
}

Second Service:
public class HelloWorldPublisherByServer2 {
    public static void main(String[] args) {
        Endpoint.publish("http://localhost:9992/ws/hello", new HelloWorldImplByService2());
    }
}

HelloWorldImplByService1 class implementation:
@WebService(endpointInterface = "com.mkyong.ws.first.HelloWorldService1")
public class HelloWorldImplByService1 implements HelloWorldService1 {
 
  @Override
  public String getHelloWorldAsStringByService1(String name) throws MBFault {
    return "111 Hello World JAX-WS " + name;
  }
}

HelloWorldImplByService2 class implementation:
@WebService(endpointInterface = "com.mkyong.ws.second.HelloWorldService2")
public class HelloWorldImplByService2 implements HelloWorldService2 {
    @Override
    public String getHelloWorldAsStringByService2(String name) throws MBFault {
        return "222 Hello World JAX-WS " + name;
    }
}

The HelloWorldImplByService1 and HelloWorldImplByService2 classes are similar.
their methods throw my exception: MBFault.
Implementation of HelloWorldService1 Interface:
@WebService
@SOAPBinding(style = Style.DOCUMENT, use=Use.LITERAL)
public interface HelloWorldService1 {
 	@WebMethod String getHelloWorldAsStringByService1(String name) throws MBFault;
}

The HelloWorldService2 interface is almost identical to the HelloWorldService1 interface.
my MBFault exception is one for both services:
@WebFault(name = "MBFault", targetNamespace = "http://fault.ws.mkyong.com/")
public class MBFault extends Exception {

    private String detail;

    public MBFault(String message, String detail) {
        super(message);
        this.detail = detail;
    }

    public MBFault(String message, String detail, Throwable cause) {
        super(message, cause);
        this.detail = detail;
    }

    public String getDetail() {
        return detail;
    }
}

Based on two services, I can generate two WSDLs and generate two clients,
(using wsimport).
As a result, I get a duplicate of my MBFault exception. How can I avoid duplicating this class?, And is it possible to somehow explicitly specify when creating the service - in which folder the client will be stored, and in which MBFault exception?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question