0
votes

Hi guys first of all I want you to see my wsdl file it's DHL24 api I want learn a bit on this and use simple example here is the link https://dhl24.com.pl/webapi.html

I want to use getVersion as you can see we don't need to provide any data to this only in response we have getVersionResult - STRING

First of all I created package generated from apache CTX using simple project here is POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.test</groupId>
<artifactId>DhlServiceClient</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>
    <apache.cxf-version>2.5.9</apache.cxf-version>
</properties>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${apache.cxf-version}</version>
            <executions>
                <execution>
                    <id>Wsdl2Java - gasShopService.wsdl</id>
                    <phase>generate-sources</phase>
                        <configuration>
                        <sourceRoot>${basedir}/src/main/java/</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${basedir}/src/main/resources/dhlService.wsdl</wsdl>
                                <extraargs>
                                    <extraarg>-client</extraarg>
                                    <extraarg>-autoNameResolution</extraarg>
                                    <extraarg>-p</extraarg>
                                    <extraarg>pl.test</extraarg>
                                    <extraarg>-aer=false</extraarg>
                                    <extraarg>-verbose</extraarg>
                                    <extraarg>-frontend</extraarg>
                                    <extraarg>jaxws21</extraarg>
                                    <extraarg>-wsdlLocation </extraarg>
                                    <extraarg>classpath:dhlService.wsdl</extraarg>
                                </extraargs>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

All is fine here I have package and classes so I start to create second project (as dependency I added this package - this works fine)

Now I want to create simple flow:

<flow name="getVersion" doc:name="getVersion">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="getVersion" doc:name="HTTP"/>

<logger doc:name="getVersion" message="Test Before" level="ERROR"/>
<cxf:jaxws-client operation="getVersion" clientClass="pl.test.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">
</cxf:jaxws-client>

<logger doc:name="getVersion" message="Test after" level="ERROR"/>
</flow>

Nothing big but when I post to this I have:

ERROR 2014-06-28 20:36:10,289 [[gaspoldhlservice].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Test Before ERROR 2014-06-28 20:36:10,291 [[gaspoldhlservice].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy: **************************************************************************** Message : wrong number of arguments. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: ContentLengthInputStream Code
: MULE_ERROR--2 -------------------------------------------------------------------------------- Exception stack is: 1. wrong number of arguments (java.lang.IllegalArgumentException) sun.reflect.NativeMethodAccessorImpl:-2 (null) 2. wrong number of arguments. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: ContentLengthInputStream (org.mule.api.transport.DispatchException)
org.mule.module.cxf.CxfOutboundMessageProcessor:150 -------------------------------------------------------------------------------- Root Exception stack trace: java.lang.IllegalArgumentException: wrong number of arguments at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)


I was searching a bit in google and found something like this. I add after inbound:

<object-to-byte-array-transformer />

And I had other error:

ERROR 2014-06-28 20:45:18,149 [[gaspoldhlservice].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Test Before ERROR 2014-06-28 20:45:18,151 [[gaspoldhlservice].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy: **************************************************************************** Message : wrong number of arguments. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: byte[] Code : MULE_ERROR--2 -------------------------------------------------------------------------------- Exception stack is: 1. wrong number of arguments (java.lang.IllegalArgumentException) sun.reflect.NativeMethodAccessorImpl:-2 (null) 2. wrong number of arguments. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: byte[] (org.mule.api.transport.DispatchException)
org.mule.module.cxf.CxfOutboundMessageProcessor:150 -------------------------------------------------------------------------------- Root Exception stack trace: java.lang.IllegalArgumentException: wrong number of arguments at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)


I need a little bit push here its very simple method and I cant handle it right ...

AFTER EDIT:

Changed to your flow with:

<flow name="getVersion" doc:name="getVersion">
   <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="getVersion" doc:name="HTTP"/>


<cxf:jaxws-client operation="getVersion" serviceClass="pl.test.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">
</cxf:jaxws-client>

<http:outbound-endpoint exchange-pattern="request-response"  address="http://localhost:8088/consumeTest" doc:name="HTTP" method="POST"/>

</flow>

<flow name="consumeTest" doc:name="consumeTest">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="consumeTest" doc:name="HTTP"/>
    <logger doc:name="getVersion" message="Test AFTER" level="ERROR"/>
</flow>

Answer is

No such operation: getVersion. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: ContentLengthInputStream

When I use clientClass instead of serviceClass:

wrong number of arguments. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: ContentLengthInputStream

2

2 Answers

0
votes

You need to put an outbound endpoint after cxf:jaxws-client like <http:outbound-endpoint exchange-pattern="request-response" address="Your external webservice path that you are tying to consume " doc:name="HTTP" method="POST"/> to post the value to the external webservice .. for example If your external webservice is at http://localhost:8086/mainData?wsdl then you need to put

<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8086/mainData" doc:name="HTTP" method="POST"/> ................ and one more thing ... could you plase change <cxf:jaxws-client operation="getVersion" clientClass="pl.execon.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP"> to

`<cxf:jaxws-client operation="getVersion" serviceClass="pl.execon.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">`  in your flow and try ...

So the final flow would be something like :-

 <flow name="getVersion" doc:name="getVersion">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="getVersion" doc:name="HTTP"/>


    <cxf:jaxws-client operation="getVersion" serviceClass="pl.execon.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">
    </cxf:jaxws-client>

    <http:outbound-endpoint exchange-pattern="request-response"  address="Your external webservice path that you are tying to consume " doc:name="HTTP" method="POST"/>
    </flow>
0
votes

AFTER EDIT:

Changed to your flow with:

<flow name="getVersion" doc:name="getVersion">
   <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="getVersion" doc:name="HTTP"/>


<cxf:jaxws-client operation="getVersion" serviceClass="pl.test.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">
</cxf:jaxws-client>

<http:outbound-endpoint exchange-pattern="request-response"  address="http://localhost:8088/consumeTest" doc:name="HTTP" method="POST"/>

</flow>

<flow name="consumeTest" doc:name="consumeTest">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="consumeTest" doc:name="HTTP"/>
    <logger doc:name="getVersion" message="Test AFTER" level="ERROR"/>
</flow>

Answer is

No such operation: getVersion. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: ContentLengthInputStream

When I use clientClass instead of serviceClass:

wrong number of arguments. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: ContentLengthInputStream