I have to communicate with a Soap Webservice and currently I am consuming it through a client built using the Java library Axis2, and everything is going well, but I need to migrate this client for Apache CXF because we have other clients through Apache CXF and when we have Axis2 and Apache Cxf in the same classpath we have some conflicts because of different implementations of XmlSchema that both libraries use.
The problem is when using Apache Cxf the response are being sent in html and not soap as you can see through this stacktrace we are receiving:
javax.xml.ws.soap.SOAPFaultException: Response was of unexpected text/html ContentType. Incoming portion of HTML stream: <html>
...
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:157)
...
at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:84)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:835)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1614)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1504)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1310)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:628)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
.. 27 more
I have inspected both request and both seem the same as you can see here:
Axis 2 Request
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header>
<axis2ns10:login xmlns:axis2ns10="http://auth.smssp.atech.br">LOGIN</axis2ns10:login>
<axis2ns11:password xmlns:axis2ns11="http://auth.smssp.atech.br">PASSWORD</axis2ns11:password>
<axis2ns12:sistema xmlns:axis2ns12="http://auth.smssp.atech.br">SYSTEM</axis2ns12:sistema>
</soapenv:Header>
<soapenv:Body>
<ser:pesquisar xmlns:ns2="http://service.smssp.atech.br">
<ser:numeroCNS>11111111</ser:numeroCNS>
<ser:carregarObjetoCompleto>true</ser:carregarObjetoCompleto>
</ser:pesquisar>
</soapenv:Body>
</soapenv:Envelope>
Apache CXF Request
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<login xmlns="http://auth.smssp.atech.br">LOGIN</login>
<password xmlns="http://auth.smssp.atech.br">PASSWORD</password>
<sistema xmlns="http://auth.smssp.atech.br">SYSTEM</sistema>
</soap:Header>
<soap:Body>
<ns2:pesquisar xmlns="http://domain.smssp.atech.br/xsd" xmlns:ns2="http://service.smssp.atech.br" xmlns:ns3="http://searchFilter.infra.smssp.atech.br/xsd">
<ns2:numeroCNS>11111111</ns2:numeroCNS>
<ns2:carregarObjetoCompleto>true</ns2:carregarObjetoCompleto>
</ns2:pesquisar>
</soap:Body>
</soap:Envelope>
Any idea what the problem can be?
Best Regards,
João
Related
I have deployed a WAR file with SOAP endpoints and created a handler to detect any call for all web services that the client may call. I want to detect the nonexistent web service but unfortunately, I am getting errors on Payara only if I deployed the WAR file on any other application server (glassfish or Tomcat) it works as expected the error has been logged by the handler. Here is an example for request/response using SOAPUi and web services deploy on Payara.
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.jaxws.demo.jcg/">
soapenv:Header/
soapenv:Body
ser:getBooks
1
</ser:getBooks>
</soapenv:Body>
</soapenv:Envelope>
Response:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
S:Server
java.lang.NullPointerException
</S:Fault>
</S:Body>
</S:Envelope>
I am getting this error on server.log
[2023-01-15T16:49:30.029+0300] [Payara 5.2021.7] [SEVERE] [AS-WSSECURITY-00001] [javax.enterprise.webservices.security] [tid: _ThreadID=740 _ThreadName=http-thread-pool::http-listener-2(620)] [timeMillis: 1673790570029] [levelValue: 1000] [[
Request processing failed.
java.lang.NullPointerException
at java.util.ArrayDeque.addLast(ArrayDeque.java:249)
at org.glassfish.api.invocation.InvocationManagerImpl.pushWebServiceMethod(InvocationManagerImpl.java:386)
at org.glassfish.webservices.MonitoringPipe.pushWebServiceMethod(MonitoringPipe.java:211)
at org.glassfish.webservices.MonitoringPipe.process(MonitoringPipe.java:132)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:89)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1106)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1020)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:989)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:847)
at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106)
at com.sun.enterprise.security.webservices.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:195)
at com.sun.enterprise.security.webservices.CommonServerSecurityPipe.process(CommonServerSecurityPipe.java:134)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:89)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1106)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1020)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:989)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:847)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:389)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:838)
The request/response for the same web service deployed on glassfish
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.jaxws.demo.jcg/">
soapenv:Header/
soapenv:Body
ser:getBooks
1
</ser:getBooks>
</soapenv:Body>
</soapenv:Envelope>
Response:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">SOAP-ENV:Header/<S:Body><S:Fault xmlns:ns3="http://www.w3.org/2003/05/soap-envelope">S:Client
Cannot find dispatch method for {http://service.jaxws/}getfBook
</S:Fault>
</S:Body>
</S:Envelope>
I have gone through this posted question earlier, however my issue is different:
org.apache.axis2.AxisFault: javax.xml.stream.XMLStreamException:
Premature end of file encountered at
org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
org.apache.axis2.AxisFault: javax.xml.stream.XMLStreamException:
Premature end of file encountered at
org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:122)
at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:66)
at
org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:347)
at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:414)
at
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
at
org.apache.axis2.client.OperationClient.execute(OperationClient.java:150)
Can anybody help me out please what I'm missing as this is working perfectly fine in my local machine. But failing onto my server environment.
Please let me know if more details are required.
I had added this jars in my server Web-Inf :
Please have a look at this SOAP request that we are hitting :
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:tem="http://tempuri.org/">
<soap:Header>
<tem:UserAuth>
<!--Optional:-->
<tem:UserName>?</tem:UserName>
<!--Optional:-->
<tem:Password>?</tem:Password>
</tem:UserAuth>
</soap:Header>
<soap:Body>
<tem:Cities/>
</soap:Body>
</soap:Envelope>
Recently I got a requirement from one of our customer. They provided a WSDL to call their service. They are doing IP whitelisting for authentication. I gave my server public IP and it got whitelisted. First, I tested that service through SOAP UI tool and it got worked without any issues. Then I integrated through JAVA code and it got failed. I am getting an exception like
Unable to sendViaPost to url[https://apps.greystar.com/gsWebService/gsExtract.asmx]
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.handleResponse(HTTPSenderImpl.java:343) ~[axis2-transport-http-1.7.1.jar:1.7.1]
at org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.sendViaPost(HTTPSenderImpl.java:213) ~[axis2-transport-http-1.7.1.jar:1.7.1]
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:121) [axis2-transport-http-1.7.1.jar:1.7.1]
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:403) [axis2-transport-http-1.7.1.jar:1.7.1]
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:234) [axis2-transport-http-1.7.1.jar:1.7.1]
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:431) [axis2-kernel-1.7.1.jar:1.7.1]
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:399) [axis2-kernel-1.7.1.jar:1.7.1]
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225) [axis2-kernel-1.7.1.jar:1.7.1]
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:150) [axis2-kernel-1.7.1.jar:1.7.1]
at com.reputation.r4e.integrator.greystar.ExtractDataStub.greystarExtract(ExtractDataStub.java:300) [classes/:na]
at com.reputation.r4e.integrator.recordreader.GreystarLocationImportRecordReader.getGreystarExtractResponse(GreystarLocationImportRecordReader.java:198) [classes/:na]
at com.reputation.r4e.integrator.recordreader.GreystarLocationImportRecordReader.process(GreystarLocationImportRecordReader.java:97) [classes/:na]
at com.reputation.r4e.integrator.impl.DefaultPipeline.flow(DefaultPipeline.java:33) [classes/:na]
at com.reputation.r4e.integrator.impl.DefaultPipeline.process(DefaultPipeline.java:52) [classes/:na]
at com.reputation.r4e.integrator.importer.NullImporter.process(NullImporter.java:38) [classes/:na]
at com.reputation.r4e.integrator.impl.DefaultPipeline.flow(DefaultPipeline.java:33) [classes/:na]
at com.reputation.r4e.integrator.impl.DefaultPipeline.process(DefaultPipeline.java:52) [classes/:na]
at com.reputation.r4e.integrator.IntegrationRunner$IntegrationRunnable.run(IntegrationRunner.java:87) [classes/:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
It's saying 401 unauthorised error. How it got worked through SOAP UI and why its not working through a JAVA client.?
I monitor http traffic through TCPMon and except headers all are same. So I added the headers which got from the SOAP UI tool to my JAVA Client but still no luck. I am getting the same 401 unauthorised error.
Here are the soap request of both SOAP UI and through JAVA Client.
SOAP UI Request:
POST https://apps.greystar.com/gsWebService/gsExtract.asmx HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/soap+xml;charset=UTF-8;action="https://apps.greystar.com/greystarExtract"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Content-Length: 692
Host: apps.greystar.com
Connection: Keep-Alive
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:apps="https://apps.greystar.com/">
<soap:Header/>
<soap:Body>
<apps:greystarExtract>
<apps:axmlVendorCode>VENDOR_CODE</apps:axmlVendorCode>
<apps:axmlToken>PASSWORD</apps:axmlToken>
<apps:axmlExtractType>PROPERTY_LIST</apps:axmlExtractType>
<apps:axmlFormat>XML</apps:axmlFormat>
<apps:axmlParameters></apps:axmlParameters>
</apps:greystarExtract>
</soap:Body>
</soap:Envelope>
JAVA CLIENT Request:
POST /gsWebService/gsExtract.asmx HTTP/1.1
Content-Type: application/soap+xml; charset=UTF-8; action="https://apps.greystar.com/greystarExtract
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36[\r][\n]
Connection: Keep-Alive
Host: apps.greystar.com
Transfer-Encoding: chunked
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header />
<soapenv:Body>
<ns1:greystarExtract xmlns:ns1="https://apps.greystar.com/">
<ns1:axmlVendorCode>VENDOR_CODE</ns1:axmlVendorCode>
<ns1:axmlToken>PASSWORD</ns1:axmlToken>
<ns1:axmlExtractType>PROPERTY_LIST</ns1:axmlExtractType>
<ns1:axmlFormat>JSON</ns1:axmlFormat>
<ns1:axmlParameters></ns1:axmlParameters>
</ns1:greystarExtract>
</soapenv:Body>
</soapenv:Envelope>
Note: I added JAVA Client headers by looking at the SOAP UI headers. The actual JAVA client headers are below
POST /gsWebService/gsExtract.asmx HTTP/1.1
Content-Type: application/soap+xml; charset=UTF-8;
action="https://apps.greystar.com/greystarExtract
User-Agent: Axis2
Host: apps.greystar.com
Transfer-Encoding: chunked
What could be the reason for failing this through JAVA client.? Can any one please answer my question because I stuck over here.
Thanks in advance,
Amar.T
I tried other third party libraries and its working as expected. I tried CXF and SOAP UI JAVA API and its working as expected. I don't know why its not working with APACHE AXIS2.
If anyone finds the answer why its not working with AXIS2 please post the answer.
Thanks & Regards,
Amar.T
My intention is to send ebxml message to MSH (Hermes2 http://www.cecid.hku.hk/hermes.php) through another Hermes2.
I am sending fairly simple message (with no attachments), this is the message:
POST /corvus/httpd/ebms/sender HTTP/1.0
User-Agent: PEAR-SOAP 0.12.0-beta
Host: 10.0.4.9
Content-Type: text/xml; charset=UTF-8
Content-Length: 698
SOAPAction: "PaymentAddRequest"
Connection: close
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<cpaId>ZSK_KOLEK</cpaId>
<service>http://www.squiz.pl/zsk/ebxml</service>
<action>PaymentAddRequest</action>
<convId>convId</convId>
<fromPartyId>KOLEK</fromPartyId>
<fromPartyType>urn:oasis:names:tc:ebxml-cppa:partyid-type:duns</fromPartyType>
<toPartyId>ZSK-C</toPartyId>
<toPartyType>urn:oasis:names:tc:ebxml-cppa:partyid-type:duns</toPartyType>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
In response I get following:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<message_id xmlns="http://service.ebms.edi.cecid.hku.hk/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" type="xsd:string">20150112-092001-65410#127.0.1.1</message_id>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Message gets registered, but then in logs/ebms.log I get following error
[Thread-1855 ] <ERROR> <cecid.ebms.spa> <Error in outbox task>
hk.hku.cecid.ebms.spa.task.MessageValidationException: Cannot reconstruct the message 20150112-092435-20713#127.0.1.1 from repository
by java.lang.RuntimeException: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source:
by com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source:
by javax.xml.transform.TransformerException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
Also looking at repository table in DB I can see that a row has been inserted, content column contains message in hex form (\x3c3f786d6c2076657273696f6e3d...), once converted to ASCII it says:
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/ http://www.oasis-open.org/committees/ebxml-msg/schema/envelope.xsd">
<SOAP-ENV:Header xsi:schemaLocation="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
<eb:MessageHeader SOAP-ENV:mustUnderstand="1" eb:version="2.0" xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
<eb:From>
<eb:PartyId eb:type="urn:oasis:names:tc:ebxml-cppa:partyid-type:duns">KOLEK</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId eb:type="urn:oasis:names:tc:ebxml-cppa:partyid-type:duns">ZSK-C</eb:PartyId>
</eb:To>
<eb:CPAId>ZSK_KOLEK</eb:CPAId>
<eb:ConversationId>convId</eb:ConversationId>
<eb:Service>http://www.squiz.pl/zsk/ebxml</eb:Service>
<eb:Action>PaymentAddRequest</eb:Action>
<eb:MessageData>
<eb:MessageId>20150112-092435-20713#127.0.1.1</eb:MessageId>
<eb:Timestamp>2015-01-12T09:24:35.207+01:00</eb:Timestamp>
</eb:MessageData>
<eb:DuplicateElimination/>
</eb:MessageHeader>
<eb:SyncReply SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" SOAP-ENV:mustUnderstand="1" eb:version="2.0" xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd"/>
<eb:AckRequested SOAP-ENV:actor="urn:oasis:names:tc:ebxml-msg:actor:toPartyMSH" SOAP-ENV:mustUnderstand="1" eb:signed="false" eb:version="2.0" xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd"/>
</SOAP-ENV:Header>
<SOAP-ENV:Body xsi:schemaLocation="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd"/>
</SOAP-ENV:Envelope>
but it doesn't get delivered to the endpoint, seems like Hermes2 doesn't even try to send it to the second Hermes2. Both instances have proper partnership configured.
Can someone point me in the right direction?
Ok, it took me a longer while to find the issue and then a solution, so hopefully I can save someones time.
Documentation on Hermes 2 installation says that it requires PostgreSQL 8.0 or later. This is a lie! Removing Postgres 9.3 and reinstalling Hermes with Postgres 8.4 solved the problem.
I use Mule 3.5.0
I have a mule configuration where I accept HTTP requests, I add a SOAP header to them and I forward them to an external service and the result of that service call is returned:
Since I want to see what happens I write the generated request and response messages to folders. (Requests and Responses components).
For testing purposes I created a test method using the MuleClient functionality:
#Test
public void testOnlineServiceFlow() throws Exception
{
MuleClient client = new MuleClient(muleContext);
MuleMessage result = client.send("http://localhost:1234/in", "<acc:AccountDetailsRequest xmlns:acc=\"http://com/blog/samples/webservices/accountservice\"><acc:accountNumber>12345</acc:accountNumber></acc:AccountDetailsRequest>", null);
System.out.println(result.getPayloadAsString());
}
Everything works fine and after executing my test my response message is written to the folder location by the Responses component:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns3:AccountDetailsResponse xmlns:ns2="http://webservices.samples.blog.com" xmlns:ns3="http://com/blog/samples/webservices/accountservice">
<ns3:AccountDetails>
<ns2:AccountNumber>12345</ns2:AccountNumber>
<ns2:AccountName>Joe Bloggs</ns2:AccountName>
<ns2:AccountBalance>3400.0</ns2:AccountBalance>
<ns2:AccountStatus>Active</ns2:AccountStatus>
</ns3:AccountDetails>
</ns3:AccountDetailsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But then when my message returns in my client and I want to print it, I got following exception:
org.mule.api.transformer.TransformerException: Could not read InputStream.
at org.mule.transformer.simple.ObjectToString.createStringFromInputStream(ObjectToString.java:83)
at org.mule.transformer.simple.ObjectToString.doTransform(ObjectToString.java:54)
at org.mule.transformer.AbstractTransformer.transform(AbstractTransformer.java:419)
at org.mule.DefaultMuleMessage.getPayload(DefaultMuleMessage.java:375)
at org.mule.DefaultMuleMessage.getPayloadAsString(DefaultMuleMessage.java:630)
at org.mule.DefaultMuleMessage.getPayloadAsString(DefaultMuleMessage.java:565)
at be.healthconnect.handicare.OnlineServiceTest.testOnlineServiceFlow(OnlineServiceTest.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:46)
at org.junit.internal.runners.statements.FailOnTimeout$1.run(FailOnTimeout.java:28)
Caused by: java.io.IOException: Bad chunk size: HTTP/1.1 500 Internal Server Error
at org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:306)
at org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
at org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
at java.io.FilterInputStream.read(Unknown Source)
at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:108)
at java.io.FilterInputStream.read(Unknown Source)
at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:127)
at org.mule.model.streaming.DelegatingInputStream.read(DelegatingInputStream.java:54)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1792)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744)
at org.mule.transformer.simple.ObjectToString.createStringFromInputStream(ObjectToString.java:78)
... 18 more
I don't know what the reason of this failure and how I could resolve it. Probably something is wrong in my flow configuration?
<flow name="Online_Service" doc:name="Online_Service">
<http:inbound-endpoint exchange-pattern="request-response" name="clientEndpoint" address="http://localhost:1234/in" doc:name="HTTP" contentType="text/xml"/>
<component doc:name="SOAP Header Creator">
<spring-object bean="SoapHeaderCreatorBean"/>
</component>
<file:outbound-endpoint path="C:/mule/Online/OUT" responseTimeout="10000" doc:name="Requests"/>
<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8080/spring-webservices-sample/endpoints" doc:name="HTTP" method="POST" />
<file:outbound-endpoint path="C:/mule/Online/OUT" responseTimeout="10000" doc:name="Responses"/>
</flow>
It seems that the http:outbound endpoint is giving you a stream and the file outbound endpoint is consuming this. You should put a transformer (such as object-to-string) after the http outbound endpoint so as to make sure that the stream is stored in memory and not consumed before the response is given back to the http inbound endpoint.