[mule-user] Difficulty invoking a service via cxf:jaxws-client

636 views
Skip to first unread message

Todd Gould

unread,
Oct 21, 2011, 1:40:54 PM10/21/11
to us...@mule.codehaus.org
Hello,

Sorry for the newbie question, but I have been searching and reading the docs and cannot seem to locate the source of the problem. I am attempting to read a message from a file (containing XML) and then invoke a service with the contents. I am working with the Bookstore example as a starting point.

My flow is:

<flow name="test-service">
<file:inbound-endpoint path="C:/TEMP" connector-ref="inbox">
<file:filename-wildcard-filter pattern="order.xml"/>
</file:inbound-endpoint>

<cxf:jaxws-client
serviceClass="org.mule.example.bookstore.OrderService"
port="OrderServiceImplPort"
operation="orderBook"/>
<outbound-endpoint address="http://localhost:8777/services/order"/>
</flow>

I have unsucessfully tried to have the order.xml file contain just an orderBook element as follows:

<?xml version="1.0" encoding="UTF-8"?>

<ns2:orderBook xmlns:ns2="http://bookstore.example.mule.org/">
<book>
<author>J.R.R. Tolkien</author>
<id>1</id>
<price>8.0</price>
<title>The Fellowship of the Ring</title>
</book>
<quantity>4</quantity>
<address>Someplace, Somewhere</address>
<email>m...@my-mail.com</email>
</ns2:orderBook>


ans also tried to with it as a full SOAP message as follows:

<?xml version="1.0" encoding="UTF-8"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:orderBook xmlns:ns2="http://bookstore.example.mule.org/">
<book>
<author>J.R.R. Tolkien</author>
<id>1</id>
<price>8.0</price>
<title>The Fellowship of the Ring</title>
</book>
<quantity>4</quantity>
<address>Someplace, Somewhere</address>
<email>m...@my-mail.com</email>
</ns2:orderBook>
</soap:Body>
</soap:Envelope>

Either way, I end up getting errors such as:

java.lang.IllegalArgumentException: argument type mismatch
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.apache.cxf.databinding.AbstractWrapperHelper.createWrapperObject(AbstractWrapperHelpe
r.java:99)
at org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOu
tInterceptor.java:103)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:471)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:310)
at org.mule.module.cxf.CxfOutboundMessageProcessor.doSendWithClient(CxfOutboundMessageProces
sor.java:231)
at org.mule.module.cxf.CxfOutboundMessageProcessor.process(CxfOutboundMessageProcessor.java:
125)
at org.mule.processor.AbstractInterceptingMessageProcessor.processNext(AbstractInterceptingM
essageProcessor.java:57)
at org.mule.processor.builder.InterceptingChainMessageProcessorBuilder$InterceptingMessagePr
ocessorAdapter.process(InterceptingChainMessageProcessorBuilder.java:188)
at org.mule.processor.AbstractInterceptingMessageProcessor.processNext(AbstractInterceptingM
essageProcessor.java:57)
at org.mule.processor.builder.InterceptingChainMessageProcessorBuilder$InterceptingMessagePr
ocessorAdapter.process(InterceptingChainMessageProcessorBuilder.java:188)
at org.mule.processor.AbstractInterceptingMessageProcessor.processNext(AbstractInterceptingM
essageProcessor.java:57)
at org.mule.processor.builder.InterceptingChainMessageProcessorBuilder$InterceptingMessagePr
ocessorAdapter.process(InterceptingChainMessageProcessorBuilder.java:188)
at org.mule.processor.AbstractInterceptingMessageProcessor.processNext(AbstractInterceptingM
essageProcessor.java:57)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(As
yncInterceptingMessageProcessor.java:184)
at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:41)
at org.mule.work.WorkerContext.run(WorkerContext.java:309)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExe
cutor.java:1061)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolEx
ecutor.java:575)
at java.lang.Thread.run(Unknown Source)
INFO 2011-10-21 11:36:54,213 [[default].flow.test-service.1] org.apache.cxf.phase.PhaseInterceptorC
hain: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault
at org.apache.cxf.databinding.AbstractWrapperHelper.createWrapperObject(AbstractWrapperHelpe
r.java:107)
at org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOu
tInterceptor.java:103)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:471)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:310)
at org.mule.module.cxf.CxfOutboundMessageProcessor.doSendWithClient(CxfOutboundMessageProces
sor.java:231)
at org.mule.module.cxf.CxfOutboundMessageProcessor.process(CxfOutboundMessageProcessor.java:
125)
at org.mule.processor.AbstractInterceptingMessageProcessor.processNext(AbstractInterceptingM
essageProcessor.java:57)
at org.mule.processor.builder.InterceptingChainMessageProcessorBuilder$InterceptingMessagePr
ocessorAdapter.process(InterceptingChainMessageProcessorBuilder.java:188)
at org.mule.processor.AbstractInterceptingMessageProcessor.processNext(AbstractInterceptingM
essageProcessor.java:57)
at org.mule.processor.builder.InterceptingChainMessageProcessorBuilder$InterceptingMessagePr
ocessorAdapter.process(InterceptingChainMessageProcessorBuilder.java:188)
at org.mule.processor.AbstractInterceptingMessageProcessor.processNext(AbstractInterceptingM
essageProcessor.java:57)
at org.mule.processor.builder.InterceptingChainMessageProcessorBuilder$InterceptingMessagePr
ocessorAdapter.process(InterceptingChainMessageProcessorBuilder.java:188)
at org.mule.processor.AbstractInterceptingMessageProcessor.processNext(AbstractInterceptingM
essageProcessor.java:57)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(As
yncInterceptingMessageProcessor.java:184)
at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:41)
at org.mule.work.WorkerContext.run(WorkerContext.java:309)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExe
cutor.java:1061)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolEx
ecutor.java:575)
at java.lang.Thread.run(Unknown Source)
ERROR 2011-10-21 11:36:54,260 [[default].flow.test-service.1] org.mule.exception.DefaultServiceExcep
tionStrategy:
********************************************************************************
Message : null (org.apache.cxf.interceptor.Fault)
Type : org.mule.api.DefaultMuleException
Code : MULE_ERROR-10999
JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/DefaultMuleE
xception.html
********************************************************************************
Exception stack is:
1. null (org.apache.cxf.interceptor.Fault)
org.apache.cxf.databinding.AbstractWrapperHelper:107 (null)
2. null (org.apache.cxf.interceptor.Fault) (org.mule.api.DefaultMuleException)
org.mule.module.cxf.CxfOutboundMessageProcessor:139 (http://www.mulesoft.org/docs/site/current3/ap
idocs/org/mule/api/DefaultMuleException.html)
********************************************************************************
Root Exception stack trace:
org.apache.cxf.interceptor.Fault
at org.apache.cxf.databinding.AbstractWrapperHelper.createWrapperObject(AbstractWrapperHelpe
r.java:107)
at org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOu
tInterceptor.java:103)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:471)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:310)
at org.mule.module.cxf.CxfOutboundMessageProcessor.doSendWithClient(CxfOutboundMessageProces
sor.java:231)
at org.mule.module.cxf.CxfOutboundMessageProcessor.process(CxfOutboundMessageProcessor.java:
125)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(As
yncInterceptingMessageProcessor.java:184)
at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:41)
at org.mule.work.WorkerContext.run(WorkerContext.java:309)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExe
cutor.java:1061)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolEx
ecutor.java:575)
at java.lang.Thread.run(Unknown Source)

********************************************************************************

What am I missing/doing wrong?

TIA!

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Todd Gould

unread,
Oct 21, 2011, 3:14:29 PM10/21/11
to us...@mule.codehaus.org
Hello,

Sorry for the newbie question, but I have been searching and reading the
docs and cannot seem to locate the source of the problem. I am
attempting to read a message from a file (containing XML) and then
invoke a service with the contents. I am working with the Bookstore
example as a starting point.

My flow is:

&lt;flow name="test-service"&gt;
&lt;file:inbound-endpoint path="C:/TEMP" connector-ref="inbox"&gt;
&lt;file:filename-wildcard-filter pattern="order.xml"/&gt;
&lt;/file:inbound-endpoint&gt;

&lt;cxf:jaxws-client
serviceClass="org.mule.example.bookstore.OrderService"
port="OrderServiceImplPort"
operation="orderBook"/&gt;
&lt;outbound-endpoint address="http://localhost:8777/services/order"/&gt;
&lt;/flow&gt;

I have unsucessfully tried to have the order.xml file contain just an orderBook element as follows:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;ns2:orderBook xmlns:ns2="http://bookstore.example.mule.org/"&gt;
&lt;book&gt;
&lt;author&gt;J.R.R. Tolkien&lt;/author&gt;
&lt;id&gt;1&lt;/id&gt;
&lt;price&gt;8.0&lt;/price&gt;
&lt;title&gt;The Fellowship of the Ring&lt;/title&gt;
&lt;/book&gt;
&lt;quantity&gt;4&lt;/quantity&gt;
&lt;address&gt;Someplace, Somewhere&lt;/address&gt;
&lt;email&gt;m...@my-mail.com&lt;/email&gt;
&lt;/ns2:orderBook&gt;

ans also tried to with it as a full SOAP message as follows:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
&lt;soap:Body&gt;
&lt;ns2:orderBook xmlns:ns2="http://bookstore.example.mule.org/"&gt;
&lt;book&gt;
&lt;author&gt;J.R.R. Tolkien&lt;/author&gt;
&lt;id&gt;1&lt;/id&gt;
&lt;price&gt;8.0&lt;/price&gt;
&lt;title&gt;The Fellowship of the Ring&lt;/title&gt;
&lt;/book&gt;
&lt;quantity&gt;4&lt;/quantity&gt;
&lt;address&gt;Someplace, Somewhere&lt;/address&gt;
&lt;email&gt;m...@my-mail.com&lt;/email&gt;
&lt;/ns2:orderBook&gt;
&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;

INFO 2011-10-21 11:36:54,213 [[http://default].flow.test-service.1|http://default].flow.test-service.1/] org.apache.cxf.phase.PhaseInterceptorC

ERROR 2011-10-21 11:36:54,260 [[http://default].flow.test-service.1|http://default].flow.test-service.1/] org.mule.exception.DefaultServiceExcep


tionStrategy:
********************************************************************************
Message : null (org.apache.cxf.interceptor.Fault)
Type : org.mule.api.DefaultMuleException
Code : MULE_ERROR-10999
JavaDoc : [http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/DefaultMuleE]
xception.html
********************************************************************************
Exception stack is:
1. null (org.apache.cxf.interceptor.Fault)
org.apache.cxf.databinding.AbstractWrapperHelper:107 (null)
2. null (org.apache.cxf.interceptor.Fault) (org.mule.api.DefaultMuleException)

org.mule.module.cxf.CxfOutboundMessageProcessor:139 ([http://www.mulesoft.org/docs/site/current3/ap]

David Dossot

unread,
Oct 21, 2011, 7:46:22 PM10/21/11
to us...@mule.codehaus.org
If you're builiding the SOAP envelope (instead of letting CXF create it from POJOs), you should then either look at http://www.mulesoft.org/documentation/display/MULE3USER/Proxying+Web+Services+with+CXF or even simply an HTTP outbound endpoint POSTing your payload.

HTH
D.

Todd Gould

unread,
Oct 21, 2011, 8:02:44 PM10/21/11
to us...@mule.codehaus.org
David, thanks for your reply. As I mentioned, I have tried both without the SOAP envelope (my preference) as well as with as a last resort. Neither is working and both produce the same error I indicated. If we assume I want to proceed without the SOAP envelope, can you advise what is wrong with my flow? Again, I'm attempting to invoke the Bookstore OrderService for simplicity at this point.

Thanks again!

David Dossot

unread,
Oct 21, 2011, 8:16:56 PM10/21/11
to us...@mule.codehaus.org
Usually to invoke a web service, you need to follow one of these approaches: http://www.mulesoft.org/documentation/display/MULE3USER/Consuming+Web+Services+with+CXF

Then you create the object you want to pass to your web service (one of those generated from the WSDL) and pass it to your flow, for example via a VM transport.

If you want to read the values from a file and create your object from these values, you can either store the serialized object itself in the file and deserialize it or use any format in the file and use a transformer to build the object from the values read from the file.

HTH
D.

Todd Gould

unread,
Oct 21, 2011, 8:33:45 PM10/21/11
to us...@mule.codehaus.org

Is there any way to send in the XML version of the object in correspondence with what the WSDL expects - i.e. in my case an Order object represented in it's XML format?

David Dossot

unread,
Oct 21, 2011, 8:40:59 PM10/21/11
to us...@mule.codehaus.org
You need to deserialize the XML version to an object instance and let CXF serialize it towards the WSDL specs.

Todd Gould

unread,
Oct 24, 2011, 12:02:42 PM10/24/11
to us...@mule.codehaus.org
David,

thanks again for your help. I am trying to get the XML unmarshalled into the objects needed for cxf:jaxws-client
with the &lt;xm:xml-to-object-transformer name="XmlToObject" /&gt;. However, the transformer does not seem to know what classes to use (and I'm not sure how to tell it which classes to use, etc as the documentation does not show any other available options). So I am now seeing errors like: Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: ns2:orderBook : ns2:orderBook
at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:49)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:76
)

How can I get the XML orderBook unmarshalled into the Java objects needed for cxf:jaxws-client?

David Dossot

unread,
Oct 24, 2011, 12:15:03 PM10/24/11
to us...@mule.codehaus.org
How can I get the XML orderBook unmarshalled into the Java objects needed for cxf:jaxws-client?

It depends on how the XML orderBook has been marshalled. If it's been marshalled with XStream then xml-to-object-transformer is the good option, but from the error you get, it doesn't seem like it. If it's been marshalled with JAXB then use the jaxb-xml-to-object-transformer.

HTH
D.

Todd Gould

unread,
Oct 24, 2011, 2:07:27 PM10/24/11
to us...@mule.codehaus.org
Sorry again for the newbie questions, but I not sure how it is being marshalled. From looking at the BookStore sample code, it appears that order.jsp uses a JaxWsProxyFactoryBeanto invoke CXF web service. It creates the service from this object and then passes the Java objects to it as part of the invocation. I see no reference to any specific marshalling, but it must be happening somewhere in there?

David Dossot

unread,
Oct 24, 2011, 2:13:03 PM10/24/11
to us...@mule.codehaus.org
Sorry I'm confused, I thought you were loading the orderBook object from order.xml.

In the bookstore example, order.jsp doesn't use Mule to invoke the CatalogService. I don't think this is what you're looking for, or I am really totally confused :)

Todd Gould

unread,
Oct 24, 2011, 2:52:56 PM10/24/11
to us...@mule.codehaus.org
David,

You are correct. I loading the orderBook object from
order.xml. Since you asked how the object was marshalled in an earlier post, I was looking at the order.jsp (which invokes the OrderService) to see how it marshalled it. (I captured the contents of order.xml by inserting a &lt;logging-interceptor/&gt; into the bookstore-config.xml) - this is where the contents of that file originated from. So, I'm still stuck as to know how they got from the Java objects I see used near the bottom of order.jsp to the marshalled XML that I see from the logging-interceptor just before invoking the OrderService?

I hopeful to be able to unmrshall the XML and invoke the OrderService myself as a simple starting point ... Hence this thread of discussion. HTH.

Todd Gould

unread,
Oct 24, 2011, 3:14:00 PM10/24/11
to us...@mule.codehaus.org
Now I am confused.... Having already tried XStream xmlToObject (as discussed earlier) without success I guessed that the bookstore sample must be using JAXB if it was not XStream. However, this does not appear to be the case either: (Caused by: javax.xml.bind.JAXBException: "org.mule.example.bookstore" doesnt contain ObjectFactory.class or jaxb.index), so I am really not sure how they objects get marshalled into XML in the sample???

David Dossot

unread,
Oct 24, 2011, 3:17:12 PM10/24/11
to us...@mule.codehaus.org
Hey Todd,

I loading the orderBook object from order.xml.  Since you asked how the object was marshalled in an earlier post, I was looking at the order.jsp (which invokes the OrderService) to see how it marshalled it.  (I captured the contents of order.xml by inserting a &lt;logging-interceptor/&gt; into the bookstore-config.xml) - this is where the contents of that file originated from.

Aaahh. OK!
 
So, I'm still stuck as to know how they got from the Java objects I see used near the bottom of order.jsp to the marshalled XML that I see from the logging-interceptor just before invoking the OrderService?

This is done by the orderService proxy created by CXF's JaxWsProxyFactoryBean.

By default CXF uses JAXB for marshaling: I was about to say that it's what's been used but the Order object is not JAXB-annotated so I'm wondering if a fallback to another serializer (like Aegis) has occurred.
 
I hopeful to be able to unmrshall the XML and invoke the OrderService myself as a simple starting point ... Hence this thread of discussion.  HTH.

Got it now. At the end of the day, for your particular use case of loading the object from a file, you should use any marshaling scheme you want.

D.
 

Todd Gould

unread,
Oct 24, 2011, 3:54:55 PM10/24/11
to us...@mule.codehaus.org
But I don't need to marshall it.... I need to unmarshall what was marshalled by the bookstore sample? ... Which does not appear to be JAXB either.... I think I'm still stuck for getting going here.

David Dossot

unread,
Oct 24, 2011, 4:16:09 PM10/24/11
to us...@mule.codehaus.org
I think this conversation needs a good reboot.

What is it you are trying to achieve with Mule, independently of the bookstore example?

Todd Gould

unread,
Oct 24, 2011, 4:41:49 PM10/24/11
to us...@mule.codehaus.org
Ultimately, I will have XML on the inbound side. I'll process the XML via various XSLT and/or Java based tranforms and then deliver it to service on the outbound side. So starting from the sample was hoped to be both an expidicuous and low-risk way of developing a proof of concept as well as providing well-know to the community areas if we ran into troubles/questions. As an aside, while working in parallel here, I have gotten this desired flow to work as desired via the proxying method you suggested - thanks. This will work just fine for the XSLT only tranforms. In those cases where I need to unmarshall to objects and apply some sort of Java based transform, it makes the most sense to ultimately use the cxf:jaxws-client ... hence the continued desired to find a way to make that approach workable. Thanks again for your help!

David Dossot

unread,
Oct 24, 2011, 5:49:33 PM10/24/11
to us...@mule.codehaus.org

Ultimately, I will have XML on the inbound side.  I'll process the XML via various XSLT and/or Java based tranforms and then deliver it to service on the outbound side.  So starting from the sample was hoped to be both an expidicuous and low-risk way of developing a proof of concept as well as providing well-know to the community areas if we ran into troubles/questions.  As an aside, while working in parallel here, I have gotten this desired flow to work as desired via the proxying method you suggested - thanks.

That's great news.
 
This will work just fine for the XSLT only tranforms.  In those cases where I need to unmarshall to objects and apply some sort of Java based transform, it makes the most sense to ultimately use the cxf:jaxws-client ... hence the continued desired to find a way to make that approach workable.

It is fully workable provided you can have consistency in the marshalling/unmarshalling used. With the XML payload you've captured, we don't know for sure the marshaller that was used (Aegis?) so that is what it is hard to move forward with this data.

Try the following: create an Order object in a test class and serialize it with XStream, storing the result in a file. With this in hand, and using the xml-to-object transformer, you'll have your File->Object->CXF->WebService flow working in no time.

D.

Todd Gould

unread,
Oct 25, 2011, 2:29:07 PM10/25/11
to us...@mule.codehaus.org
Thanks again David!
Reply all
Reply to author
Forward
0 new messages