Hello back.

As I did not receive any response to get out of this, I tried it another
way:
I replace the camel component by a bean component, and get rid of the cxf
provider.

Here is how I did:
All is done in the java class.
7a) the xbean of the bean is:
<beans xmlns:bean="http://servicemix.apache.org/bean/1.0"; 
           xmlns:hello="urn:test:helloWorld">

  <bean:endpoint service="hello:HelloService" endpoint="helloEndpoint">
      <bean:bean>
          <bean class="fr.hello.MyHello" />
      </bean:bean>
  </bean:endpoint>
</beans>

7b) the java class is:

public class MyHello implements MessageExchangeListener {
        private static final String jaxbContext1 = 
"org.apache.servicemix.test3";
    @Resource
    DeliveryChannel channel;
    
    public void onMessageExchange(MessageExchange exchange) throws
MessagingException {
        InOut inOut = (InOut) exchange;
        if (inOut.getStatus() == ExchangeStatus.DONE) {
            return;
        } else if (inOut.getStatus() == ExchangeStatus.ERROR) {
            return;
        }
       
System.out.println("------------------------------------------------------------");
        try {
                        Source input = inOut.getInMessage().getContent();

                        // XML UNMARSHAL
                        JAXBContext jc = JAXBContext.newInstance(jaxbContext1);
                        Unmarshaller u = jc.createUnmarshaller();
                        Object appDefaults = u.unmarshal(input);
                        String inputWS = ((JAXBElement<String>) 
appDefaults).getValue();

                        System.out.println("--------" + inputWS + "--------");

                    // generate the SOAP output
                    HelloWorld hw = new HelloWorld();
                    HelloWorldPortType client = 
hw.getHelloWorldSOAP11PortHttp();
                    // call the web service
                    String output = client.hello(inputWS);

                    System.out.println("--------" + output + "--------");

                    // XML MARSHAL
                        JAXBContext context = 
JAXBContext.newInstance(jaxbContext1);
                        Marshaller marshaller = context.createMarshaller();
                        
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
                        ByteArrayOutputStream baos = new 
ByteArrayOutputStream();
                        marshaller.marshal(new 
ObjectFactory().createMessage(output), baos);

                        // generate the answer
                        NormalizedMessage answer = inOut.createMessage();
                        answer.setContent(new StringSource(baos.toString()));
                        inOut.setOutMessage(answer);
                        channel.send(inOut);

        } catch (Exception e) {
            inOut.setError(e);
            channel.send(inOut);
        }
       
System.out.println("------------------------------------------------------------");
    }
}

Here are the sources of my projects:
the "TestWsdlDistant3-backup4-3su+jaxb+cxf" is the working system without
transformation. Feel free to include it in some examples or tutorial as you
don't have any cxf provider example (only consumer). Thanks to you for
helping me doing this ;)
the "TestWsdlDistant3" is what I was expecting since the beginning. A simple
system http-consumer + bean that connects to a distant WS.

http://www.nabble.com/file/p23850640/solutions.zip solutions.zip 

Again, thanks for your help.
-- 
View this message in context: 
http://www.nabble.com/components-to-use-for-an-XML-to-SOAP-request-tp23745527p23850640.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to