wsimport - how to generate service endpoint classes and JAXB classes in separate projects/folders

前端 未结 4 896
清酒与你
清酒与你 2020-12-16 00:49

We are using a top-down approach for a project with multiple web services (multiple WSDL\'s). Each web service needs to be set up as a separate project and deployed as a sep

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-16 01:30

    Usually what I've seen using the IBM Rational toolset:

    Generate all the JAXB and service classes and store them with the service project. Then regenerate the JAXB and service client classes and store them in a client project.

    Yes, this is duplication. But I think the reasoning behind it is that it separates the concerns of service providers and service consumers. From a toolset perspective, how do you know if your client is .NET, C++, or Java? Or vice versa. If you are a client, how do you know if the provider is .NET, C++, or Java, etc? You don't. Thus IBM provides this way of separation of concerns.

    Now the downside to that is that you have duplicate code, if you happen to have the source for both the service provider and the consumer. This can be a pain to maintain.

    So perhaps it would be best to generate the service and the client into a Java project (not a J2EE project or a web project) and make a jar out of it. This way, all the JAXB classes are there (and only once). The WSDL is there (once). The service is there once and can be deployed to the server in either an EAR or WAR. And the client exists in case you want to give that to someone to consume your service. If your client allows for dynamic creation based on the WSDL location, even better.

    I've got a post that may help you with that from a wizard driven perspective. It is more related to security, but you may find some helpful tips from it.

提交回复
热议问题