Changing the URL on a webservice client generated with wsimport

前端 未结 2 753
轻奢々
轻奢々 2021-01-02 01:52

I am trying to write a module for a Java application that accesses a WSDL-described webservice. The source WSDL was downloaded straight from what I believe to be an ASP.NET

2条回答
  •  轮回少年
    2021-01-02 02:28

    This answer has been eluding me for a couple of days, but somehow the act of writing the question always focuses me on finding an answer, and a couple more websearches have pointed to it:

    http://www.fransvanbuul.net/?p=98

    It seems that wsimport created a class, com.example.WebService, which extends javax.xml.ws.Service. This WebService class has two constructors. The no-arg constructor is hardcoded with a file:// URL to use the original WSDL I generated from. (I suppose that if I had supplied an https:// URL on the wsimport command-line, that would be the URL that is hardcoded.) Alternatively I can use a two-arg constructor and supply a WSDL URL at instantiation time! This approach requires me to also supply a javax.xml.namespace.QName object, which I don't yet understand, as the second argument.

    Using this two-arg constructor will probably resolve my problem.

    It seems that wsimport, which I am using from JDK 1.6, is a part of the JAX-WS package. JDK 1.6, in recent versions, contains JAX-WS 2.1, and JAX-WS 2.2 will address the difficulties I am raising in this question.

    I'll be happy to accept any answer that explains some or all of the rest of this situation. I still don't understand why the WSDL is needed at runtime. More practically, it would help me for someone to show me how to use the two-argument constructor, or how to generate my code with JDK 1.6 and JAX-WS 2.2.

提交回复
热议问题