WS wrong namespace URI generated

I want to connect to a SOAP service.

using wsimport I've generated classes from a remote wsdl

My code:

    Lists listsService = new Lists();
    ListsSoap lisoap = listsService .getListsSoap(); 

    ((BindingProvider) si).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "MY_USER");
    ((BindingProvider) si).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "“MY_PASS");

    ((BindingProvider) si).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://<SOME_REMOTE_URL>/Lists.asmx");


   GetListCollectionResult coll = si.getListCollection();

I've traced the request xml:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap1="http://schemas.microsoft.com/sharepoint/soap/">
   <S:Header/>
   <S:Body>
      <soap1:GetListCollection/>
   </S:Body>
</S:Envelope>

http://schemas.xmlsoap.org/soap/envelope - is wrong!

Returns empty result, both in java and SOAP-UI

the correct URI should be http://www.w3.org/2003/05/soap-envelope

It works in SOAP-UI but i don't know how to set it in java for JAX-WS

I suspect it's related to SOAP version 1 vs 1.2

UPDATE:
Tried to run this:

 soapEnv.setAttributeNS("http://schemas.xmlsoap.org/soap/envelope/", "S", "http://www.w3.org/2000/xmlns/");

But the output now is:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" ns0:S="http://www.w3.org/2000/xmlns/">

Almost good but not enoguh


solution is trivial...

ListsSoap lisoap = listsService.getListsSoap12(); 

it returns the service for SOAP 1.2


if you generated code from the WSDL with JAX-WS the URI mapping should be fine, but authentication with HTTP-BASIC coudl cause issues used with your code. Maybe this can help:

JAX WS client cannot authenticate

it refers to an authentication problem.

链接地址: http://www.djcxy.com/p/35308.html

上一篇: SOAP服务器1.1使用为1.2定义的内容类型发送响应?

下一篇: WS生成错误的名称空间URI