[mule-user] Difficulty passing message to cxf:jaxws-client

3 views
Skip to first unread message

Adam Haapala

unread,
Feb 7, 2011, 11:04:13 AM2/7/11
to us...@mule.codehaus.org
Hi, I'm new to Mule ESB and need some help getting some things working, so please bear with me if I don't always use the correct parlance or seem confused about certain aspects of the framework. Right now I'm trying to get a simple example working where any type of inbound-endpoint (currently set up to use stdio) passes its message to the cxf:jaxws soap client and I write the response to file or stdio. This is my current mule-config.xml file.


<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xm="http://www.mulesoft.org/schema/mule/xml"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:script="http://www.mulesoft.org/schema/mule/scripting"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/3.1/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.1/mule-http.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.1/mule-stdio.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/3.1/mule-xml.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.1/mule-file.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/3.1/mule-cxf.xsd">

<file:connector name="OutputFile" outputPattern="mule-test-soap.txt" />
<stdio:connector name="stdioConnector" messageDelayTime="1234" outputMessage="abc" promptMessage="bcd" promptMessageCode="456" />

<flow name="TestFlow">

<stdio:inbound-endpoint name="in" system="IN" connector-ref="stdioConnector" exchange-pattern="request-response" />

<cxf:jaxws-client operation="login" clientClass="<service class>" port="Soap" wsdlLocation="/path/to/wsdl/file" />

<file:outbound-endpoint path="/home/myhomedir" connector-ref="OutputFile" outputPattern="mule-test-soap.txt" />
<stdio:outbound-endpoint name="out" system="OUT" connector-ref="stdioConnector" />

</flow>
</mule>

I used apache cxf to generate the service classes from the wsdl file and am pretty sure I'm pointing the cxf tag to the correct one. So when I go to run this mule config I get the following errror.

ERROR 2011-02-07 10:11:40,673 [stdioConnector.receiver.1] org.mule.exception.DefaultServiceExceptionStrategy:
********************************************************************************
Message : wrong number of arguments (java.lang.IllegalArgumentException)
Code : MULE_ERROR-10999
--------------------------------------------------------------------------------

When I go through the code that actually implements what the login method for the soap call is doing it's requiring two arguments, username and password. I'm assuming the message being passed in by the inbound-endpoint is the username and password needed to make a successful login call to the soap service but I'm really lost as to what's the correct format or way to pass this information. If any one can help me with this it's greatly appreciated. Please let me know if there's any additional information I can provide to help clarify this issue.

Thanks,
~Adam~

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

http://xircles.codehaus.org/manage_email


Adam Haapala

unread,
Feb 8, 2011, 4:45:19 PM2/8/11
to us...@mule.codehaus.org
This is now a bit of a moot point after I tried using the sfdc salesforce transport although I'm now floundering on how to successfully direct the message returned from a sfdc:query. Here's the snippet of code I'm looking at now.


<enricher target="#[variable:query]" source="#[bean:records]">
<sfdc:query query="select id, name from Account where Name='Test'" batchsize="20" config-ref="salesforce" />
</enricher>


<expression-transformer>
<return-argument evaluator="variable" expression="query"/>
</expression-transformer>

<expression-transformer>
<file:outbound-endpoint path="/home/ahaapala" connector-ref="OutputFile" outputPattern="mule-test-soap.txt" />
</expression-transformer>

The return-argument method works well but the file outbound-endpoint is tossing me this error


ERROR 2011-02-08 16:18:59,497 [OutputFile.dispatcher.1] org.mule.exception.DefaultServiceExceptionStrategy:
********************************************************************************
Message : An invalid return type "class java.io.InputStream" was specified for transformer "JAXBMarshallerTransformer"
Code : MULE_ERROR-65267
--------------------------------------------------------------------------------
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)
--------------------------------------------------------------------------------

Please let me know what I'm doing wrong.

Roko Kruze

unread,
Feb 8, 2011, 4:44:02 PM2/8/11
to us...@mule.codehaus.org
Hi Adam,

So I believe the issue you have here is that when the message comes in from stdio it is coming in as a single string. The call you are trying to make probably takes in two string parameters, namely a username and password. In order for CXF to accept these parameters they must be in an array. This could be done by calling out to a component or transformer. More information about building transformers or a component can be found here: http://www.mulesoft.org/documentation/display/MULE3USER/Developing+Components

HTH,
-Roko

Roko Kruze

unread,
Feb 9, 2011, 3:37:20 AM2/9/11
to us...@mule.codehaus.org
Hi Adam,

The reason for the error is that you have an array of SObjects from salesforce which cannot be converted to the needed InputStream for the outbound file endpoint. I'm testing a transformer to help with this now and will let you know how to retrieve it when I'm finished, which should be later today.

Thanks,
-Roko

Tomas Blohm

unread,
Feb 9, 2011, 5:47:17 AM2/9/11
to us...@mule.codehaus.org
Hi,

a simple way just for testing is to add a ObjectToString Transformer on the file endpoint I think.

/Tomas Blohm

Roko Kruze

unread,
Feb 9, 2011, 8:19:52 PM2/9/11
to us...@mule.codehaus.org
Adam,

I have an updated version of the SF connector on the site, version 3.0.1. With that the query brings back a list of MuleSObjects which are just extended hashmaps. There is also a transformer you can use to easily get this into a string format.

<mule-sobjects-to-string-transformer/>

This should help when sending it out to a file.

Let me know if you run into any further issues with the connector.

Thanks,
-Roko

Adam Haapala

unread,
Feb 10, 2011, 12:09:31 PM2/10/11
to us...@mule.codehaus.org
Can you give me an example of how I need to use this transformer? Is it supposed to be applied in the response stanza after the http:inbound-endpoint

(e.g.

<http:inbound-endpoint address="http://localhost:9898/sfquery" exchange-pattern="request-response" connector-ref="HttpConnector"/>
<response>
<sfdc:mule-sobjects-to-string-transformer/>
</response>
)

or should this be applied just before the file:outbound-endpoint such as

<sfdc:mule-sobjects-to-string-transformer />


<file:outbound-endpoint path="/home/ahaapala" connector-ref="OutputFile" outputPattern="mule-test-soap.txt" />

I've tried both but keep getting errors when invoking the inbound-endpoint.

~Adam~

Roko Kruze

unread,
Feb 10, 2011, 12:53:09 PM2/10/11
to us...@mule.codehaus.org
Adam,

You should use it in the following manner:

<sfdc:mule-sobjects-to-string-transformer />
<file:outbound-endpoint path="/home/ahaapala" connector-ref="OutputFile" outputPattern="mule-test-soap.txt" />

What error are you seeing?

Thanks,
-Roko

Adam Haapala

unread,
Feb 10, 2011, 1:15:59 PM2/10/11
to us...@mule.codehaus.org
Here's my flow

<flow name="main">
<http:inbound-endpoint address="http://localhost:9898/sfcreate" exchange-pattern="request-response" connector-ref="HttpConnector"/>
<response>
<sfdc:sobject-to-string-transformer/>
</response>



<enricher target="#[variable:query]" source="#[bean:records]">
<sfdc:query query="select id, name from Account where Name='Test'" batchsize="20" config-ref="salesforce" />
</enricher>

<expression-transformer>
<return-argument evaluator="variable" expression="query"/>
</expression-transformer>

<sfdc:mule-sobjects-to-string-transformer />
<file:outbound-endpoint path="/home/ahaapala" connector-ref="OutputFile" outputPattern="mule-test-soap.txt" />

</flow>

Here's the error

**********************************************************************
ERROR 2011-02-10 13:14:30,738 [HttpConnector.receiver.2] org.mule.exception.DefaultServiceExceptionStrategy:
********************************************************************************
Message : Failed to invoke org.mule.components.SalesForce@1d3b70d. Message payload is of type: String
Code : MULE_ERROR-29999
--------------------------------------------------------------------------------
Exception stack is:
1. org.apache.xerces.dom.ElementNSImpl (java.lang.ClassNotFoundException)
java.net.URLClassLoader$1:217 (null)
2. org/apache/xerces/dom/ElementNSImpl (java.lang.NoClassDefFoundError)
org.mule.components.SalesForce:152 (null)
3. Failed to invoke org.mule.components.SalesForce@1d3b70d. Message payload is of type: String (org.mule.api.MessagingException)
org.mule.processor.InvokerMessageProcessor:174 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.ClassNotFoundException: org.apache.xerces.dom.ElementNSImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

Thanks so much for your help!

~Adam~

Roko Kruze

unread,
Feb 10, 2011, 1:54:28 PM2/10/11
to us...@mule.codehaus.org
Adam,

I take it you are running this in eclipse? If so we use an endorsed library for Xerces which has some special installation instructions. Take a look on this page: [http://www.mulesoft.org/documentation/display/MULECDEV/Setting+Up+the+Development+Environment] and notice the section on setting up Java. Unless you are using JDK6 you will have to download the xerces and xalan jars and place them in your jdk as is explained on the page.

HTH,
-Roko

Andrew Perepelytsya

unread,
Feb 10, 2011, 2:44:34 PM2/10/11
to us...@mule.codehaus.org

Rather copy them from mule home/lib/endorsed

Adam Haapala

unread,
Feb 14, 2011, 2:30:03 PM2/14/11
to us...@mule.codehaus.org
Thanks I have those libraries installed and included as part of the project. Now I'm getting a new error when attempting to query salesforce

ERROR 2011-02-14 12:35:06,198 [HttpConnector.receiver.2] org.mule.exception.DefaultServiceExceptionStrategy:
********************************************************************************
Message : Failed to invoke org.mule.components.SalesForce@a4871e. Message payload is of type: String


Code : MULE_ERROR-29999
--------------------------------------------------------------------------------
Exception stack is:

1. null (java.lang.NullPointerException)
org.mule.components.SalesForce:155 (null)
2. Failed to invoke org.mule.components.SalesForce@a4871e. Message payload is of type: String (org.mule.api.MessagingException)


org.mule.processor.InvokerMessageProcessor:174 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:

java.lang.NullPointerException
at org.mule.components.SalesForce.sObjectsToMuleSObjects(SalesForce.java:155)
at org.mule.components.SalesForce.query(SalesForce.java:610)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

Here's my config file. Not sure what I'm doing wrong


<sfdc:config name="salesforce" username="te...@advance.net" password="abc123!!" securityToken="T9bKOCXFEsk7vGDWpGgrnent"/>


<file:connector name="OutputFile" outputPattern="mule-test-soap.txt" />

<http:connector name="HttpConnector" />
<stdio:connector name="stdio" />
<sfdc:mule-sobjects-to-string-transformer name="sobjects-transformer"/>

<flow name="main">

<http:inbound-endpoint address="http://localhost:9898/sftest" exchange-pattern="request-response" connector-ref="HttpConnector"/>
<response>
<sfdc:sobject-to-string-transformer/>

<enricher target="#[variable:query]" source="#[bean:records]">
<sfdc:query query="SELECT Id, Name, BillingCity FROM Account" batchsize="20" />


</enricher>

<expression-transformer>
<return-argument evaluator="variable" expression="query"/>
</expression-transformer>

<sfdc:mule-sobjects-to-string-transformer />
<file:outbound-endpoint path="/home/ahaapala" connector-ref="OutputFile" outputPattern="mule-test-soap.txt" />

</flow>
</mule>

Reply all
Reply to author
Forward
0 new messages