jaxb & XML & encoding problem *URGENT*
Hello,
***Do not be scared because of the length of the question please. I tried to explain problem clearly.***
I am developing a Web service for a particular client. The client has provided .wsdl and some .xsd files for me.
I used JWSDP-2.0 to generate holder classes from those .xsd files. In order to specify the root elemnen, I added "@XmlRootElement" annotation in front of the ServiceInfo class (, and also imported "javax.xml.bind.annotation.XmlRootElement"). I am using Eclipse in this project.
I prepared the Web service exactly as specified by the client, but when I test it with the client the client application cannot show the XML data that it receives as a response to its request. The client application opens a file, writes the XML response to that file and also shows the response on the client application window. However, that file is always empty and I see nothing on the client application window. I do not have the client application's source code, but I do know that client application has no bug.
NOTE: I have a guideline for developing the Web Service for this particular client and it says there: "ServiceInfo is transfered as a Unicode string, and then encoded as UTF-16."
(Actually I don't know whether this is the reason of my problem but it is still sth that should be known I guess.)
Here is the code of my method:
****************************************************************
public java.lang.String getServiceInfo() throws java.rmi.RemoteException {
JAXBContext servInfoContext = JAXBContext.newInstance("com.gw.oms.serviceinfo");//com.gw.oms.serviceinfo is the directory where all generated java (from serviceinfo.xsd file) files are stored.
. . . . .
. . . . .
// create an ObjectFactory instance, create instances of holder classes
// (root element is "serviceInfo") and set their values.
. . . . .
. . . . .
try {
StringWriter writer = new StringWriter();
Marshaller marshaller = servInfoContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-16");
marshaller.marshal(serviceInfo, writer);
return writer.toString();
} catch (JAXBException e) {
throw new RemoteException("Error marshalling serviceInfo", e);
}
}
****************************************************************
I guess the code piece in the try-catch block is true, but maybe I am continuously missing sth. Can you see any wrong thing in the code?
In order to see what is happenning in the communication between my Web Service and the client application I analyzed the traffic between them via Ethereal network sniffing tool. Here is some info:
*************************************************
FROM CLIENT TO WEB SERVICE: (Data Content of HTTP packet)
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schema.xmlsoap.org/soap/envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetServiceInfo
xmlns="http://....XXX....."/>
</soap:Body>
</soap:Envelope>
FROM WEB SERVICE TO CLIENT: (Data Content of HTTP packet)
--
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soap="http://schema.xmlsoap.org/soap/envelope"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<GetServiceInfoResult
xmlns=""/>**>> WARNING 1 <<**
<?xml version="1.0" encoding="UTF-16" standalone="yes"?>\n<serviceInfo xmlns="http://....XXX..../serviceInfo"><serviceProvider>Service Provider Name<**>> WARNING 2 <<**
</GetServiceInfoResult>
</soapenv:Body>
</soapenv:Envelope>
**>> WARNING 1 <<**: WHY IS 'XMLNS' EMPTY HERE? SHOULDN'T IT BE "http://....XXX....." ALSO?
**>> WARNING 2 <<**: WHY DON'T I SEE THE COMPLETE SERVICEINFO HERE? ONLY 1 HTTP RESPONSE PACKET IS BEING SENT TO THE CLIENT BY MY WEB SERVICE.
*************************************************
If I make Eclipse write to the console what I am sending, I see the result below:
*************************************************
<?xml version="1.0" encoding="UTF-16"?>
<serviceInfo xmlns="http://....XXX...../serviceInfo">
<serviceProvider>MY UNIVERSITY</serviceProvider>
<serviceUri>http://myserviceuri.com</serviceUri>
<signUpPage>http://signupmyservice/services/ITUServiceSoap</signUpPage>
<targetLocale>1053</targetLocale>
<localName>MIN SERVIS</localName>
<englishName>MY SERVICE</englishName>
<authenticationType>other</authenticationType>
<supportedService>
<SMS_SENDER maxSbcsPerMessage="160" maxRecipientsPerMessage="400" maxMessagesPerSend="5" maxDbcsPerMessage="0"/>
</supportedService>
</serviceInfo>
*************************************************
Somehow the client application cannot receive (or validate) the serviceinfo that my Web service sends. I suspect that sth is wrong with my Java code. Can any one see any error in this schema?
I am really stucked. Any recommendation would be very valuable for me.
Thanks & Regards

