I am using Springs WebServiceTemplate class to invoke a Tibco Web service over JMS to get a document as an attachment. The springs configuration is :


<bean id="downloadDOCservice"
class="downloaddocument.service.DownloadDocumentSe rviceImpl"
scope="prototype">
<property name="wstemplate" ref="webServiceTemplateWithoutMS" />
<property name="soapActionGetDocument"
value="/ApplicationComponents/BusinessServices/DocumentService/DocumentService.serviceagent/PortTypeEndpoint1/getDocument" />
<property name="url"
value="jms:XX.XXX.Documents1?messageType=BINARY_ME SSAGE" />
</bean>


<bean id="webServiceTemplateWithoutMS" class="org.springframework.ws.client.core.WebServi ceTemplate">
<constructor-arg ref="messageFactory" />
<property name="messageSender" ref="messageSender" />
<property name="marshaller" ref="marshaller" />
<property name="unmarshaller" ref="marshaller" />
<property name="faultMessageResolver" ref="faultMessageResolver" />
</bean>

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMe ssageFactory" />


Java code is

wstemplate.setDefaultUri(url);

wstemplate.sendAndReceive(new WebServiceMessageCallback() {

public void doWithMessage(WebServiceMessage message)
throws IOException, TransformerException {

MarshallingUtils.marshal(wstemplate.getMarshaller( ),
request, message);

SoapMessage soapMessage = (SoapMessage) message;
soapMessage.setSoapAction(soapAction);
}
}, new WebServiceMessageExtractor() {

public Object extractData(WebServiceMessage response) {
System.out.println("extractDataMethod invoked");
return response;
}
});




When I invoke the web service, I get an error and the callback method extractData() does not get invoked.The client is deployed on Tomcat, JDK 1.6 as part of a Web Application.


Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.parsers.Abstrac tSAXParser.parse(AbstractSAXParser.java:1231)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserI mpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at org.xml.sax.helpers.XMLFilterImpl.parse(Unknown Source)
at org.apache.xalan.transformer.TransformerIdentityIm pl.transform(TransformerIdentityImpl.java:484)

I have put xerces and xalan libraries in the endorsed directory but the error is the same.
The response returned by the Service as intercepted by tcpmon is:

--_NextPart_000_0002_01C3E1CC.3BB37320
Content-transfer-encoding: binary
Content-type: text/xml; charset=utf-8
Content-id: <TIBCO_START_PART>

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><ns0:ResponseGetDocument xmlns:ns0="http://www.xmlns.xx.com/yy/zzz/cms/types/DocumentService/1.0"><ns0:status>1</ns0:status><ns0:documentName>aaa.pdf</ns0:documentName></ns0:ResponseGetDocument></SOAP-ENV:Body></SOAP-ENV:Envelope>
--_NextPart_000_0002_01C3E1CC.3BB37320
Content-transfer-encoding: binary
Content-type: application/pdf
....
....