How does a wsimport generated client work?

后端 未结 2 1326
误落风尘
误落风尘 2020-12-23 17:56

Before anything else, I want you to know that I can already connect to the web service server. I\'m asking this question because I want to gain a deeper knowledge on how a w

2条回答
  •  被撕碎了的回忆
    2020-12-23 18:46

    You asked: I noticed that the actual URL of the web service is not declared in any of the classes generated. How does the client know where it needs to connect to?

    If the WSDL was downloaded using a browser and passed as input to wsimport, then the local wsdl file location is embedded into the generated code. That is why you don't see the actual service location in the generated code. It also means if you deleted the local copy of the wsdl file the generated code will not work (when inovked using a main method) .

    If the URL of the wsdl was passed as input to wsimport then that URL is embedded in the generated code, which is further used to get the actual service location. The idea is that the WSDL locations are fixed. They are expected to be in a UDDI or as a local file. This allows the actual services to move around and if they do move, you just have to modify the local copy of the wsdl file alone or update the wsdl in the UDDI. [mostly this does not happen as service locations are never IP but DNS names]

    This is why it is never a good idea to publish the wsdl in the same server where your webservice is running

提交回复
热议问题