JAX-WS client without a WSDL document file

后端 未结 4 967
醉酒成梦
醉酒成梦 2020-12-09 06:25

I am consuming a webservice soa, with netbeans (jax-ws) i use netbeans auto generate client, and all run fine, but i see that the wsdl is always downloading while the client

4条回答
  •  孤城傲影
    2020-12-09 06:34

    There are several ways, of which I will tell you two:

    1. Use a WSDL document file locally

      Save a copy of the WSDL document file and the schemma files to your project.

      ClassLoader classloader = Thread.currentThread().getContextClassLoader();
      URL wsdlLocation = classloader.getResource("MyHelloService.wsdl");
      QName serviceName= new QName("http://test.com/", "MyHelloService");
      
      MyHelloService service = new MyHelloService(wsdlLocation, serviceName);
      service.sayHello("Test");
      

      You may combine the WSDL document file with the schema files.

    2. Without a WSDL document file

      This solution requires the client generated.

      QName qname = new QName("http://thenamespace", "FooService");
      FooService service = new FooService(null, qname); // null for ignore WSDL
      Foo port = service.getFooPort();
      BindingProvider bindingProvider = (BindingProvider) port;
      bindingProvider.getRequestContext()
          .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
          "http://foo.com/soap/fooBean");
      
      // Use the service
      String result = port.doSomething(param);
      

提交回复
热议问题