Skip to main content

JAXWS/JAXB namespace issue with Axis server

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
Nytrodb
Offline
Joined: 2011-07-21

Hello,

I'm using JaxWS 2.2.3 to connect to Axis Web Services.

Attached you can find the WSDL.

After generating the stub with wsimport (wsimport.sh -Xendorsed -s src/ testws.wsdl), I tried to consume Handshake service method but I cannot get all response values.

This is the snippet of the main code:

[...]
TestWS_Service service = new TestWS_Service();
TestWS port = service.getTest();
BindingProvider bp = (BindingProvider) port;
Map<String, Object> context = bp.getRequestContext();
context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, URL);
ProtoHandshakeResult hsr = port.handshakeReq();
System.out.println("#### Server date: " + hsr.getServerDateString());
System.out.println("#### Load       : " + hsr.getLoad());
[...]

The response is:

HTTP/1.1 200 OK
Date: Thu, 21 Jul 2011 15:13:30 GMT
Server: Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 PHP/5.2.4
Content-Length: 442
Connection: close
Content-Type: text/xml
&lt;?xml version='1.0' encoding='utf-8' ?&gt;<br />&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;<br />&lt;SOAP-ENV:Body&gt;<br />&lt;ns1:handshakeResponse xmlns:ns1=&quot;http://test.company.com&quot;&gt;<br />&lt;result serverDate_string=&quot;2011-07-21 17:13:30&quot;&gt;&lt;ns1:load&gt;2&lt;/ns1:load&gt;<br />&lt;/result&gt;<br />&lt;/ns1:handshakeResponse&gt;<br />&lt;/SOAP-ENV:Body&gt;

I'm able to get serverDate_string value but I get a null value for load.
The issue seems related to the namespace prefix ns1: if I force namespace on the JAXB generated element (see line in bold below), all works fine.

[...]
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = &quot;ProtoHandshakeResult&quot;, propOrder = {&quot;load&quot;})

public class ProtoHandshakeResult {

    <strong>@XmlElement(namespace=&quot;http://test.company.com&quot;)</strong>
    protected Integer load;
    @XmlAttribute(name = &quot;serverDate_string&quot;)
    protected String serverDateString;
[...]

What's wrong in my implementation? I would avoid to modify generated code each time WSDL is modified!

Thanks for any info.

AttachmentSize
testws_wsdl.txt2.62 KB

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Nytrodb
Offline
Joined: 2011-07-21

Any idea about that issue?

Thank you.