I want to consume a JAX-WS service method. the methode is named find and accept a String as argument.
this the Mule flow :
<flow name="InvokeAWebServiceFlow1" doc:name="InvokeAWebServiceFlow1">
<file:inbound-endpoint path="C:\MuleStudio\SandBox\input" pollingFrequency="3000" responseTimeout="10000" doc:name="File"/>
<file:file-to-string-transformer encoding="UTF-8" mimeType="text/xml" doc:name="File to String"/>
<cxf:jaxws-client port="douaneWSPort" serviceClass="WSDL.DouaneWS" doc:name="SOAP" enableMuleSoapHeaders="true" operation="find"/>
<echo-component doc:name="Echo"/>
<file:outbound-endpoint path="C:\MuleStudio\SandBox\output" outputPattern="#[function:datestamp:dd-MM-yy]_#[function:systime].xml" responseTimeout="10000" doc:name="File"/>
</flow>
I put a argument into a file, in this exampl the argument is "ctr1" after i put the file into the inbound endpoint, after that the file is transformed into a String and goes to the JAX-WS client, finally the respponse is written into an output file.
when I run the flow I get as an output :
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:find xmlns:ns2="http://douane.ws/">
<id>ctr1</id>
</ns2:find>
</soap:Body>
</soap:Envelope>
the output is the SOAP the request instead of the expected SOAP Response, that should be somthing like:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:findResponse xmlns:ns2="http://douane.ws/">
<return>
<quality>medium</quality>
<price>150</price>
<idProd>ctr1</idProd>
</return>
</ns2:findResponse>
</S:Body>
</S:Envelope
>
.
The error generate is
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'invokeawebservice' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2013-05-14 11:13:15,024 [[invokeawebservice].connector.file.mule.default.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: C:\MuleStudio\SandBox\input\input.txt
INFO 2013-05-14 11:13:15,155 [[invokeawebservice].InvokeAWebServiceFlow1.stage1.02] org.mule.component.simple.LogComponent:
********************************************************************************
* Message received in service: InvokeAWebServiceFlow1. Content is: *
* '<soap:Envelope *
* xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:find *
* xmlns:ns2...[100 of 173]' *
********************************************************************************
INFO 2013-05-14 11:13:15,184 [[invokeawebservice].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.file.mule.default.dispatcher.2917880'. Object is: FileMessageDispatcher
INFO 2013-05-14 11:13:15,184 [[invokeawebservice].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.file.mule.default.dispatcher.2917880'. Object is: FileMessageDispatcher
INFO 2013-05-14 11:13:15,200 [[invokeawebservice].connector.file.mule.default.dispatcher.01] org.mule.transport.file.FileConnector: Writing file to: C:\MuleStudio\SandBox\output\14-05-13_1368522795199.xml
WARN 2013-05-14 11:13:15,261 [[invokeawebservice].InvokeAWebServiceFlow1.stage1.02] org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for {http://douane.ws/}DouaneWSService#{http://douane.ws/}find has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unexpected wrapper element {http://douane.ws/}find found. Expected {http://douane.ws/}findResponse.
at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:106)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:799)
at org.mule.module.cxf.transport.MuleUniversalConduit.dispatchMuleMessage(MuleUniversalConduit.java:280)
at org.mule.module.cxf.transport.MuleUniversalConduit$2.handleMessage(MuleUniversalConduit.java:194)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:533)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:375)
at org.mule.module.cxf.CxfOutboundMessageProcessor.doSendWithClient(CxfOutboundMessageProcessor.java:235)
at org.mule.module.cxf.CxfOutboundMessageProcessor.process(CxfOutboundMessageProcessor.java:125)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:61)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:47)
at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:95)
at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:70)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:47)
at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:106)
at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:55)
at org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:122)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker$1.process(AsyncInterceptingMessageProcessor.java:192)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker$1.process(AsyncInterceptingMessageProcessor.java:185)
at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:20)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:34)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:18)
at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:58)
at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:48)
at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:54)
at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:44)
at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:44)
at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:52)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:32)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:17)
at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:113)
at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:34)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(AsyncInterceptingMessageProcessor.java:184)
at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:43)
at org.mule.work.WorkerContext.run(WorkerContext.java:311)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
ERROR 2013-05-14 11:13:15,271 [[invokeawebservice].InvokeAWebServiceFlow1.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Unexpected wrapper element {http://douane.ws/}find found. Expected {http://douane.ws/}findResponse.. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Unexpected wrapper element {http://douane.ws/}find found. Expected {http://douane.ws/}findResponse. (org.apache.cxf.interceptor.Fault)
org.apache.cxf.interceptor.DocLiteralInInterceptor:106 (null)
2. Unexpected wrapper element {http://douane.ws/}find found. Expected {http://douane.ws/}findResponse.. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: String (org.mule.api.transport.DispatchException)
org.mule.module.cxf.CxfOutboundMessageProcessor:144 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.apache.cxf.interceptor.Fault: Unexpected wrapper element {http://douane.ws/}find found. Expected {http://douane.ws/}findResponse.
at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:106)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:799)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
Any help ??
If the webservice you want to consume is hosted, let's say at http://domain.com/ws , than your configuration should look like this:
<flow name="InvokeAWebServiceFlow1" doc:name="InvokeAWebServiceFlow1">
<file:inbound-endpoint path="C:\MuleStudio\SandBox\input" pollingFrequency="3000" responseTimeout="10000" doc:name="File"/>
<file:file-to-string-transformer encoding="UTF-8" mimeType="text/xml" doc:name="File to String"/>
<cxf:jaxws-client port="douaneWSPort" serviceClass="WSDL.DouaneWS" doc:name="SOAP" enableMuleSoapHeaders="true" operation="find"/>
<http:outbound-endpoint address="http://domain.com/ws" />
<echo-component doc:name="Echo"/>
<file:outbound-endpoint path="C:\MuleStudio\SandBox\output" outputPattern="#[function:datestamp:dd-MM-yy]_#[function:systime].xml" responseTimeout="10000" doc:name="File"/>
</flow>
You can find more informations on the topic here
Related
I'm checking Mule with SoapUI and face an issue path parameter must start with /.
Error message on Mule
WARN 2022-01-23 00:01:02,491 [http.listener.03 SelectorRunner] org.glassfish.grizzly.filterchain.DefaultFilterChain: GRIZZLY0013: Exception during FilterChain execution
java.lang.IllegalArgumentException: path parameter must start with /
at org.mule.runtime.api.util.Preconditions.checkArgument(Preconditions.java:25) ~[mule-api-1.4.0-20211227.jar:?]
at org.mule.service.http.impl.service.util.DefaultRequestMatcherRegistry.lambda$new$1(DefaultRequestMatcherRegistry.java:69) ~[mule-service-http-1.6.3.jar:1.6.3]
at com.github.benmanes.caffeine.cache.LocalLoadingCache.lambda$newMappingFunction$2(LocalLoadingCache.java:140) ~[caffeine-2.8.0.jar:?]
at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2379) ~[caffeine-2.8.0.jar:?]
at java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1853) ~[?:1.8.0_282]
at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2377) ~[caffeine-2.8.0.jar:?]
at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2360) ~[caffeine-2.8.0.jar:?]
at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:108) ~[caffeine-2.8.0.jar:?]
at com.github.benmanes.caffeine.cache.LocalLoadingCache.get(LocalLoadingCache.java:54) ~[caffeine-2.8.0.jar:?]
at org.mule.service.http.impl.service.util.DefaultRequestMatcherRegistry.find(DefaultRequestMatcherRegistry.java:260) ~[mule-service-http-1.6.3.jar:1.6.3]
at org.mule.service.http.impl.service.server.HttpListenerRegistry.getRequestHandler(HttpListenerRegistry.java:109) ~[mule-service-http-1.6.3.jar:1.6.3]
at org.mule.service.http.impl.service.server.grizzly.GrizzlyRequestDispatcherFilter.handleRead(GrizzlyRequestDispatcherFilter.java:123) ~[mule-service-http-1.6.3.jar:1.6.3]
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) ~[grizzly-framework-2.3.36-MULE-024.jar:2.3.36-MULE-024]
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) ~[grizzly-framework-2.3.36-MULE-024.jar:2.3.36-MULE-024]
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) ~[grizzly-framework-2.3.36-MULE-024.jar:2.3.36-MULE-024]
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) [grizzly-framework-2.3.36-MULE-024.jar:2.3.36-MULE-024]
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) [grizzly-framework-2.3.36-MULE-024.jar:2.3.36-MULE-024]
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) [grizzly-framework-2.3.36-MULE-024.jar:2.3.36-MULE-024]
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:540) [grizzly-framework-2.3.36-MULE-024.jar:2.3.36-MULE-024]
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) [grizzly-framework-2.3.36-MULE-024.jar:2.3.36-MULE-024]
at org.mule.service.http.impl.service.server.grizzly.ExecutorPerServerAddressIOStrategy.run0(ExecutorPerServerAddressIOStrategy.java:99) [mule-service-http-1.6.3.jar:1.6.3]
at org.mule.service.http.impl.service.server.grizzly.ExecutorPerServerAddressIOStrategy.executeIoEvent(ExecutorPerServerAddressIOStrategy.java:74) [mule-service-http-1.6.3.jar:1.6.3]
at org.glassfish.grizzly.strategies.AbstractIOStrategy.executeIoEvent(AbstractIOStrategy.java:89) [grizzly-framework-2.3.36-MULE-024.jar:2.3.36-MULE-024]
at org.glassfish.grizzly.nio.SelectorRunner.iterateKeyEvents(SelectorRunner.java:415) [grizzly-framework-2.3.36-MULE-024.jar:2.3.36-MULE-024]
at org.glassfish.grizzly.nio.SelectorRunner.iterateKeys(SelectorRunner.java:384) [grizzly-framework-2.3.36-MULE-024.jar:2.3.36-MULE-024]
at org.glassfish.grizzly.nio.SelectorRunner.doSelect(SelectorRunner.java:348) [grizzly-framework-2.3.36-MULE-024.jar:2.3.36-MULE-024]
at org.glassfish.grizzly.nio.SelectorRunner.run(SelectorRunner.java:279) [grizzly-framework-2.3.36-MULE-024.jar:2.3.36-MULE-024]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_282]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_282]
at org.mule.service.scheduler.internal.AbstractRunnableFutureDecorator.doRun(AbstractRunnableFutureDecorator.java:113) [mule-service-scheduler-1.4.1/:?]
at org.mule.service.scheduler.internal.RunnableFutureDecorator.run(RunnableFutureDecorator.java:54) [mule-service-scheduler-1.4.1/:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_282]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_282]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]
Steps
Find WSDL here (https://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL)
[Mule4.4] Create Listener and SOAP Router.
HTTP Listener config: port = 1081
SOAP configuration: Wsdl location = (URL in Step 1.)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:apikit-soap="http://www.mulesoft.org/schema/mule/apikit-soap" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/apikit-soap http://www.mulesoft.org/schema/mule/apikit-soap/current/mule-apikit-soap.xsd http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<http:listener-config name="api-httpListenerConfig">
<http:listener-connection host="0.0.0.0" port="1081"/>
</http:listener-config>
<apikit-soap:config httpStatusVarName="httpStatus" name="soapkit-config" port="NumberConversionSoap" service="NumberConversion" wsdlLocation="https://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL"/>
<flow name="api-main">
<http:listener config-ref="api-httpListenerConfig" path="/NumberConversion/NumberConversionSoap">
<http:response statusCode="#[attributes.additionalTransportData.statusCode default 200]">
<http:body>#[payload]</http:body>
<http:headers>#[attributes.protocolHeaders default {}]</http:headers>
</http:response>
<http:error-response statusCode="#[attributes.additionalTransportData.statusCode default 500]">
<http:body>#[payload]</http:body>
<http:headers>#[attributes.protocolHeaders default {}]</http:headers>
</http:error-response>
</http:listener>
<apikit-soap:router config-ref="soapkit-config">
<apikit-soap:attributes><![CDATA[#[%dw 2.0
output application/java
---
{
headers: attributes.headers,
method: attributes.method,
queryString: attributes.queryString
}]]]></apikit-soap:attributes>
</apikit-soap:router>
</flow>
<flow name="NumberToWords:\soapkit-config">
<ee:transform>
<ee:message>
<ee:set-payload>
<![CDATA[%dw 2.0
output application/java
ns soap http://schemas.xmlsoap.org/soap/envelope
---
{
body: {
soap#Fault: {
faultcode: "soap:Server",
faultstring: "Operation [NumberToWords:\soapkit-config] not implemented"
}
} write "application/xml"
}]]>
</ee:set-payload>
</ee:message>
</ee:transform>
</flow>
<flow name="NumberToDollars:\soapkit-config">
<ee:transform>
<ee:message>
<ee:set-payload>
<![CDATA[%dw 2.0
output application/java
ns soap http://schemas.xmlsoap.org/soap/envelope
---
{
body: {
soap#Fault: {
faultcode: "soap:Server",
faultstring: "Operation [NumberToDollars:\soapkit-config] not implemented"
}
} write "application/xml"
}]]>
</ee:set-payload>
</ee:message>
</ee:transform>
</flow>
</mule>
[SoapUI5.7] Create a new SOAP API with the URL in Step 1. Then create a new request (https://0.0.0.0:1081/NumberConversion/NumberConversionSoap) and run it. The message at the bottom says "failed to respond"
[Mule4.4] See the message.
Notes
I confirm Listener's Path starts with "/".
It is a warning not an error. It is most likely harmless. Ensure you are using the last version of Studio and cumulative patches for Mule 4.4. There is something strange in the log though. It looks to be executing an HTTP service for Mule 4.3 (mule-service-http-1.6.3) which is not a right version for Mule 4. May be the project is being executed in Mule 4.3? Check the log when the application is starting and the run configuration to be sure.
Details : I have created on flow in MuleESB which is calling a web-service without any parameter just sending it username, password and token in a property and it is working fine.
But the second API I want to post some parameters while calling soap request but I don't know how to use it I tried to pass through set payload but no response.
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<http:request-config name="HTTP_Request_Configuration" host="webservicehostadd" port="443" doc:name="HTTP Request Configuration">
<http:basic-authentication username="username" password="pass"/>
</http:request-config>
<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="https://xxxx/1.0?wsdl" service="xxx" port="xxxx" serviceAddress="https://xxxxx/1.0" connectorConfig="HTTP_Request_Configuration" doc:name="Web Service Consumer"/>
<flow name="mycustomflow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/TEST" doc:name="HTTP"/>
<set-property propertyName="APIKey" value="xxx-xxx-xxx-xxx-xxx" doc:name="Property"/>
<dw:transform-message doc:name="Transform Message" metadata:id="xxx-xxx-xxx-xxx-xxxxxxxx">
<dw:input-payload mimeType="application/xml"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/xml
%namespace ns0 http://localhost/getDetails:getDetailsWSD
---
{
ns0#getDetails: {
getDetailsOrder: {
ID: payload.ns0#getDetails.getDetailsOrder.ID,
AllData: payload.ns0#getDetails.getDetailsOrder.AllData
}
}
}]]></dw:set-payload>
</dw:transform-message>
<ws:consumer config-ref="Web_Service_Consumer" operation="employeeDetails" doc:name="Web Service Consumer"/>
</flow>
It showed the below error:
Exception while executing:
[row,col]: [1,1]
Unexpected character '{' (code 123) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1].
Updated answer:
<dw:transform-message metadata:id="XXXXX" doc:name="Transform Message">
<dw:set-payload><![CDATA[
%output application/xml skipNullOn="everywhere"
%namespace ns0 localhost/getDetails:getDetailsWSD
---
{
ns0#getDetails: {
getDetailsOrder: {
ID: payload.ns0#getDetails.getDetailsOrder.ID,
AllData: payload.ns0#getDetails.getDetailsOrder.AllData
}
}
}]]>
</dw:set-payload>
</dw:transform-message>
In your scenario: you are passing a body in XML format and sometimes an empty body in your Postman requests.
Passing an empty body results your payload to be {NullPayload}. To handle this, we have to remove explicitly defining the input mime type: <dw:input-payload mimeType="application/xml"/>.
In your transformation: ID: payload.ns0#getDetails.getDetailsOrder.ID,. You are retrieving a value from an empty payload and this will fail. To avoid failing, we have added: skipNullOn="everywhere". You can read more about it here.
I have tried the transformation myself which results to this:
<?xml version='1.0' encoding='UTF-8'?>
<ns0:getDetails xmlns:ns0="http://localhost/getDetails:getDetailsWSD">
<getDetailsOrder/>
</ns0:getDetails>
I think we are done with your initial issue regarding transformation of your empty payload. Your concern now is consuming the web service.
Thank you.
The inbound of the Web Service Soap Consumer states that the inbound of the component, even though I set the payload.
Here is an image of my flow (in action):
Here is the code behind the worfklow:
<flow name="getScope" doc:name="getScope">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" doc:name="HTTP" />
<echo-component doc:name="Echo"/>
<message-filter doc:name="Filter favicon">
<not-filter>
<wildcard-filter pattern="/favicon.ico" caseSensitive="true"/>
</not-filter>
</message-filter>
<set-payload doc:name="Set Payload" value="<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://xxxxx.xxxx.xxx/services/"><soapenv:Header/><soapenv:Body><ser:GetDetails><!--Optional:--><ser:request><ser:Code>xxxxxx</ser:Code></ser:request></ser:GetDetails></soapenv:Body></soapenv:Envelope>"/>
<message-properties-transformer name="contentTypeTextXML">
<add-message-property key="Content-Type" value="text/xml" />
</message-properties-transformer>
<echo-component doc:name="Echo"/>
<ws:consumer config-ref="WebService_xxxxxxxxxxxServiceBasicHttpEndpoint" operation="GetDetails" doc:name="Web Service Consumer Organisation"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
Here is the log:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Mule is up and kicking (every 5000ms) +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2014-05-27 23:43:54,004 [[traininggovau].connector.http.mule.default.receiver.02] org.mule.component.simple.LogComponent:
********************************************************************************
* Message received in service: getScope. Content is: '/' *
********************************************************************************
INFO 2014-05-27 23:43:54,015 [[traininggovau].connector.http.mule.default.receiver.02] org.mule.component.simple.LogComponent:
********************************************************************************
* Message received in service: getScope. Content is: '<soapenv:Envelope *
* xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" *
* xmlns:ser="http://traini...[100 of 291]' *
********************************************************************************
INFO 2014-05-27 23:43:54,267 [[traininggovau].connector.http.mule.default.receiver.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
INFO 2014-05-27 23:43:54,275 [[traininggovau].connector.http.mule.default.receiver.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
INFO 2014-05-27 23:43:54,275 [[traininggovau].connector.http.mule.default.receiver.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
INFO 2014-05-27 23:43:54,276 [[traininggovau].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.https.mule.default.dispatcher.1981074383'. Object is: HttpsClientMessageDispatcher
INFO 2014-05-27 23:43:54,288 [[traininggovau].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.https.mule.default.dispatcher.1981074383'. Object is: HttpsClientMessageDispatcher
INFO 2014-05-27 23:43:58,409 [[traininggovau].connector.http.mule.default.receiver.02] org.mule.transport.http.HttpsClientMessageDispatcher: Received a redirect, but followRedirects=false. Response code: 500 Internal Server Error
ERROR 2014-05-27 23:43:58,480 [[traininggovau].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : An unexpected error occurred while trying to process your request. All details have been logged.. Message payload is of type: NullPayload
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. An unexpected error occurred while trying to process your request. All details have been logged.. Message payload is of type: NullPayload (org.mule.module.ws.consumer.SoapFaultException)
org.mule.module.ws.consumer.WSConsumer$1:164 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/module/ws/consumer/SoapFaultException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.module.ws.consumer.SoapFaultException: An unexpected error occurred while trying to process your request. All details have been logged.. Message payload is of type: NullPayload
at org.mule.module.ws.consumer.WSConsumer$1.process(WSConsumer.java:164)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
In Mule I have the following flow :
there is a choice flow control which test the input and verify if the input String equals 'ctr1'.
<flow name="mediationFlow1" doc:name="mediationFlow1">
<file:inbound-endpoint path="C:\MuleStudio\SandBox\input" pollingFrequency="3000" responseTimeout="10000" doc:name="File"/>
<file:file-to-string-transformer doc:name="File to String"/>
<choice doc:name="Choice">
<when expression="payload=='ctr1'">
<cxf:jaxws-client operation="find" serviceClass="services.port.PortWS" port="portWSPort" enableMuleSoapHeaders="true" doc:name="Port"/>
<http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:8080/Actors/portWS" doc:name="portWS"/>
</when>
<otherwise >
<cxf:jaxws-client operation="find" serviceClass="services.douane.DouaneWS" port="douaneWSPort" enableMuleSoapHeaders="true" doc:name="Douane"/>
<http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:8080/Actors/douaneWS" doc:name="douaneWS"/>
</otherwise>
</choice>
<file:outbound-endpoint path="C:\MuleStudio\SandBox\output" outputPattern="#[function:datestamp:dd-MM-yy]_#[function:systime].xml " responseTimeout="10000" doc:name="Outgoing File"/>
</flow>
</mule>
the both web services call works perfectly when I run them speratly, but when I add the choice ccontrol this is what I got :
INFO 2013-05-14 15:48:07,892 [[mediation].connector.file.mule.default.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: C:\MuleStudio\SandBox\input\input.txt
INFO 2013-05-14 15:48:08,206 [[mediation].mediationFlow1.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
INFO 2013-05-14 15:48:08,216 [[mediation].mediationFlow1.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
INFO 2013-05-14 15:48:08,253 [[mediation].mediationFlow1.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
INFO 2013-05-14 15:48:08,254 [[mediation].mediationFlow1.stage1.02] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.http.mule.default.dispatcher.7073225'. Object is: HttpClientMessageDispatcher
INFO 2013-05-14 15:48:08,260 [[mediation].mediationFlow1.stage1.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.http.mule.default.dispatcher.7073225'. Object is: HttpClientMessageDispatcher
INFO 2013-05-14 15:48:09,035 [[mediation].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.file.mule.default.dispatcher.23051110'. Object is: FileMessageDispatcher
INFO 2013-05-14 15:48:09,035 [[mediation].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.file.mule.default.dispatcher.23051110'. Object is: FileMessageDispatcher
INFO 2013-05-14 15:48:09,040 [[mediation].connector.file.mule.default.dispatcher.01] org.mule.transport.file.FileConnector: Writing file to: C:\MuleStudio\SandBox\output\14-05-13_1368539289037.xml
INFO 2013-05-14 15:48:09,043 [[mediation].connector.file.mule.default.dispatcher.01] org.mule.module.xml.transformer.jaxb.JAXBContextResolver: No common Object of type 'class javax.xml.bind.JAXBContext' configured, creating a local one for: SimpleDataType{type=services.port.Port, mimeType='text/xml'}, SimpleDataType{type=java.io.InputStream, mimeType='*/*'}
ERROR 2013-05-14 15:48:09,058 [[mediation].connector.file.mule.default.dispatcher.01] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : An invalid return type "class java.io.InputStream" was specified for transformer "JAXBMarshallerTransformer"
Code : MULE_ERROR-266
--------------------------------------------------------------------------------
Exception stack is:
1. An invalid return type "class java.io.InputStream" was specified for transformer "JAXBMarshallerTransformer" (org.mule.api.transformer.TransformerException)
org.mule.module.xml.transformer.jaxb.JAXBMarshallerTransformer:122 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.transformer.TransformerException: An invalid return type "class java.io.InputStream" was specified for transformer "JAXBMarshallerTransformer"
at org.mule.module.xml.transformer.jaxb.JAXBMarshallerTransformer.doTransform(JAXBMarshallerTransformer.java:122)
at org.mule.transformer.AbstractTransformer.transform(AbstractTransformer.java:411)
at org.mule.DefaultMuleMessage.getPayload(DefaultMuleMessage.java:362)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
I'm not sure if it's coming from the choice test expression?
Although I cant find much informations on how to use the choice control flow in details.
Mule by default applies lot of transformers in the flow to convert the payload to required formats.
In the case when there is no choice router it converts the object returned into an xml string to write to file.
But with choice router it is the programmers responsibility to provide a transformer to convert the response object to an XML string.
Add the following mule-xml jaxb object to xml transformer after choice router and before writing to file-outbound.
.....
</otherwise>
</choice>
<xm:jaxb-object-to-xml-transformer name="ObjectToXML" jaxbContext-ref="MyJaxb" returnClass="java.lang.String" encoding="UTF-8"/>
Hope this helps.
When I used two HTTP endpoints in a flow, Mule throws this exception. I've found the way to deal with this problem: use the second HTTP endpoint in asynchronous mode, but it is not a good way.
ERROR DefaultSystemExceptionStrategy [[testdemo].connector.http.mule.default.receiver.03]: Caught exception in Exception Strategy: Attempted read on closed stream.
java.io.IOException: Attempted read on closed stream.
at org.apache.commons.httpclient.AutoCloseInputStream.isReadAllowed(AutoCloseInputStream.java:183)
at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:126)
at org.mule.model.streaming.DelegatingInputStream.read(DelegatingInputStream.java:58)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1025)
at org.mule.transformer.simple.ObjectToOutputHandler$3.write(ObjectToOutputHandler.java:76)
at org.mule.transport.http.HttpServerConnection.writeResponse(HttpServerConnection.java:315)
at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:164)
at org.mule.work.WorkerContext.run(WorkerContext.java:311)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
my code :
<flow doc:name="httpPost" name="httpPost">
<http:inbound-endpoint doc:name="HTTP" keep-alive="true"
exchange-pattern="request-response" host="localhost" path="service"
port="8082" />
<http:body-to-parameter-map-transformer />
<!-- This component is just set to show the message accecpted from the request -->
<scripting:component>
<scripting:script engine="groovy">
println payload['name']
return payload['name']+'123'
</scripting:script>
</scripting:component>
</flow>
<flow doc:name="httpPost" name="client">
<http:inbound-endpoint doc:name="HTTP" name="httpClient"
exchange-pattern="request-response" host="localhost" path="client"
port="8082" encoding="UTF-8" />
<http:body-to-parameter-map-transformer />
<scripting:component>
<scripting:script engine="groovy">
payload['name'] = 'opasso'
def paramstr = ""
for( param in payload){
paramstr = paramstr + "&" + param.key+ "=" + param.value
}
println "querystr:$paramstr"
return paramstr.substring(1)
</scripting:script>
</scripting:component>
<http:outbound-endpoint address="http://localhost:8082/service"
exchange-pattern="request-response" contentType="application/x-www-form-urlencoded"
method="POST" encoding="UTF-8" />
<!-- This component is just set to show the message accecpted from the request -->
<scripting:component>
<scripting:script engine="groovy">
def msg = "return payload:$payload;".toString()
println msg
return payload
</scripting:script>
</scripting:component>
</flow>
The problem is related to the funky business you're doing in the scripting:component with the streaming message payload generated by the http:outbound-endpoint. The script probably consumes the input stream, leaving it in a state where it can't used anymore.
Try adding a <object-to-string-transformer /> right after the http:outbound-endpoint to deserialize the stream into a string so the payload can be used both in the scripting:component and by Mule.