Creating webservice and client with JBossWS using Complex objects as arguments and return types

喜欢而已 提交于 2019-12-24 20:27:12

问题


I am developing a WebService and Client for it using JBoss 5.1.0GA. The JBossWs stack was already preinstalled with the binary that I downloaded and as I understand it is JBossWs 3.1.2GA

I have developed a web service using this setup and have also created a client successfully. This is what I have.

A pojo web service deployed as a war file.

@WebService
public class Service{
    @WebMethod
    public CompleObj getConfiguration() {
        CompleObj oConf = new CompleObj ();
        for (int i = 0; i < 10; i++) {
            NestObj oInst = new BOpRepoInstance("Val1", "Val2", "Val3", "Val4");
            oConf.addRepoInstance(oInst);
        }
        return oConf;
    }
}

Here,

CompleObj => is a Complex Object that has a list of type NestObj. Its getter/setters, toString and some other methods.

NextObj => has 4 variables of Type String. Its getter/setters, toString, hashCode, equals and some other methods.

Got this web service deployed successfully.

Later created a client using the eclipse wizard for generating Web Service Client using WSDL document. It also created a sample client file which would call the webservice and fetch the return value. This also worked like a charm.

Now my problem is, when eclipse generated stubs for clients it created classes for CompleObj and NestObj. These classes only has the variables and its getters/setters (this make sense as these are being generated from WSDL doc). Thus i loose a lot of other methods that includes toString, hasCode, equals etc, which I want to use at the Client side as well.

Now how can I make use of the actual class files defined in the WebService project directly and avoid the client to use the generated ones. I can provide the class files as .jar binary for the Client project, I cant really get how to achieve this.

Another question is, the web service location is embedded in the stubs directly, what can i do to have the webservice location passed as part of the argument to the invocation code?


回答1:


  1. The classes which are generated in the client side are just place holders it is not deserilized version of your own classes,When you invoke the service it is used to carry your object to server then the JBOOSWS will do the JAXB mapping to the actual classes. So you can not make the your own classes to be used in the client side though they are look same.

  2. URL will be fixed in the stub code, since in eclipse while generating WS client the first thing you must provide is, the WSDL URL,then eclipse will generate the client code accordingly,so generated code is specific to the WSDL you provided. If you want to pass the WSDL dynamically,then you need to have your own code to generate the client stubs by passed WSDL URL using any WSDLtoJAVA or any other utility.



来源:https://stackoverflow.com/questions/11047361/creating-webservice-and-client-with-jbossws-using-complex-objects-as-arguments-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!