JAXB Connection Returning BOM Character and failing

xemidamureg

New Member
I have a 3rd party web service that I would like to consume.The problem I am having is that this service is replying with a BOM (Byte Order Marker). So when I receive this response and the response is parsed into XML, it fails. Am am not parsing the response into XML, I assume this is being done by the JAXB connection that I am using.\[code\]TInoxicoCommercial service = new TInoxicoCommercial();InoxicoCommercial binding = service.getWSHttpBindingInoxicoCommercial();String result = binding.searchCommercial(username, password, registrationNo, companyName, vatNumber, taxNumber, reference, consent, "", 1);\[/code\]The error I get when I run this code is:\[code\]com.sun.xml.internal.ws.protocol.soap.MessageCreationException: Couldn't create SOAP message due to exception: XML reader error: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]Message: Content is not allowed in prolog. at com.sun.xml.internal.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:283) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:180) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:83) at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:105) at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587) at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546) at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531) at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428) at com.sun.xml.internal.ws.client.Stub.process(Stub.java:211) at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:124) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78) at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107) at $Proxy31.searchCommercial(Unknown Source) at za.co.onlineintelligence.inoxico.CompanyRequestWrapper.request(CompanyRequestWrapper.java:43) at za.co.onlineintelligence.inoxico.CompanyRequestWrapper.main(CompanyRequestWrapper.java:14)Caused by: com.sun.xml.internal.ws.streaming.XMLStreamReaderException: XML reader error: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]Message: Content is not allowed in prolog. at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.wrapException(XMLStreamReaderUtil.java:256) at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.next(XMLStreamReaderUtil.java:84) at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.nextContent(XMLStreamReaderUtil.java:99) at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.nextElementContent(XMLStreamReaderUtil.java:89) at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:164) at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:292) at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:118)Couldn't create SOAP message due to exception: XML reader error: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1] at com.sun.xml.internal.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:278) ... 15 moreMessage: Content is not allowed in prolog.Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]Message: Content is not allowed in prolog. at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:594) at com.sun.xml.internal.ws.util.xml.XMLStreamReaderFilter.next(XMLStreamReaderFilter.java:81) at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.next(XMLStreamReaderUtil.java:65) ... 21 more\[/code\]I don't have control over the code in that webservice, but I do have contact with them and have been discussing this issue. Here is the WSDL file: https://testservices.inoxico.com/InoxicoCommercial/InoxicoCommercial.svc?wsdlI have a feeling the BOM character is being added by Microsoft Servers they are running on. Also this service has been consumed successfully from other languages such as C#.Using soapUI I have been able to test the webservice and it is responding correctly. The response I am getting looks like this (minus the BOM character):\[code\]<?xml version="1.0" encoding="utf-16"?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">https://services.inoxico.com/InoxicoCommercial/InoxicoCommercial/SearchCommercialResponse</a:Action></s:Header><s:Body><SearchCommercialResponse xmlns="https://services.inoxico.com/InoxicoCommercial"><SearchCommercialResult><?xml version="1.0" encoding="UTF-16"?><InoxicoCommercial xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://services.inoxico.com/InoxicoCommercial/InoxicoCommercial.xsd"><SearchCriteria><ProviderIndicator>INOXICO</ProviderIndicator><RegistrationNumber></RegistrationNumber><CompanyName>Google</CompanyName><VatNumber></VatNumber><TaxNumber></TaxNumber></SearchCriteria><Commercial MatchResult="M" EnquiryID=""><MultipleCommercial CommercialID="da80c534-1884-489a-a701-e9861654f066" RegistrationNo="2002/090250/23" CommercialName="GOOGLE COMMERCIAL" BusinessStatus="Deregistration Final" Suburb="SOMERSET WEST" LastUpdate="2010-11-24" /><MultipleCommercial CommercialID="7752471c-6993-4074-a282-e48a8d6d2614" RegistrationNo="2003/013898/23" CommercialName="GOOGLE SEARCH" BusinessStatus="Deregistration Final" Suburb="SOMERSET WEST" LastUpdate="2010-11-24" /><MultipleCommercial CommercialID="84ce54b6-63fa-47b2-b74e-d328201b48c3" RegistrationNo="2009/044323/23" CommercialName="GOOGLENCO TRADING" BusinessStatus="In Business" Suburb="MODDERFONTEIN" LastUpdate="2010-11-24" /><MultipleCommercial CommercialID="5c26749c-ea90-461b-9025-8174574b0fdf" RegistrationNo="2009/091720/23" CommercialName="GOOGLES NIGHT CLUB AND LOUNGE" BusinessStatus="In Business" Suburb="NIGEL" LastUpdate="2010-11-24" /></Commercial></InoxicoCommercial></SearchCommercialResult></SearchCommercialResponse></s:Body></s:Envelope>\[/code\]
 
Back
Top