Question

Im trying to consume this webservice: http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl from another wsdl... Dont worry for that, im just tryng to make some kind of bridge to test the webservice call with not logic at all, so, the flow that i need is something like that

cxf:jaxws-service --- > Java bean ----> externalWebservice

The problem is that i cant find how to call through my java impl class the external webservice, i need to inject that in my bean but i cant find how to do it. ACtualy my flow is this:

    <flow name="soapservice" doc:name="soapservice">
        <http:inbound-endpoint exchange-pattern="request-response"
            address="http://localhost:60603/Hello" doc:name="HTTP" />
        <cxf:jaxws-service serviceClass="org.example.HelloWorld"
            doc:name="SOAP" />
        <component class="org.example.HelloWorldImpl" doc:name="Java" />
    </flow>

Everything works fine, the service returns the entry parameter, but i need to retrieve some data from the Weather Webservice. Somebody can help me to consume that webservice with CXF?

Thanks!

Was it helpful?

Solution

For this, the best is to create another flow with a request-response VM inbound and a CXF client to consume the remote web service. The following explains how to generate the CXF client: http://www.mulesoft.org/documentation/display/current/Consuming+Web+Services+with+CXF

Then you can inject this other flow in your component via Component Bindings (see: http://www.mulesoft.org/documentation/display/current/Component+Bindings). That way org.example.HelloWorldImpl will have the possibility to call the remote web service via an interface call that behind the scene calls a flow that performs the CXF client interaction.

So in your case, assuming:

  • the CXF-generated service interface is com.cdyne.wsf.WeatherWS,
  • the method you're interested in is getCityWeatherByZip,
  • the CXF-generate service client is com.cdyne.wsf.WeatherWS_Service,
  • the org.example.HelloWorld class can receive an instance of com.cdyne.wsf.WeatherWS by injection

you would have something similar to:

<flow name="soapservice">
    <http:inbound-endpoint exchange-pattern="request-response"
        address="http://localhost:60603/Hello" />
    <cxf:jaxws-service serviceClass="org.example.HelloWorld" />
    <component class="org.example.HelloWorldImpl">
        <binding interface="com.cdyne.wsf.WeatherWS"
            method="getCityWeatherByZip">
            <vm:outbound-endpoint path="callGetCityWeatherByZip"
                exchange-pattern="request-response" />
        </binding>
    </component>
</flow>

<flow name="getCityWeatherByZip">
    <vm:inbound-endpoint path="callGetCityWeatherByZip"
        exchange-pattern="request-response" />

    <cxf:jaxws-client
        clientClass="com.cdyne.wsf.WeatherWS_Service"
        port="WeatherSoap" operation="GetCityWeatherByZip" />

    <http:outbound-endpoint
        address="http://wsf.cdyne.com/WeatherWS/Weather.asmx"
        exchange-pattern="request-response" />
</flow>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top