camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "viral.patel69" <viral.pa...@algorhythm.co.in>
Subject how to pass parameter to camel custom datafotmat?
Date Tue, 11 Feb 2014 08:58:49 GMT
I am new to camel

i have implemented custom dataformat

*Now i want to use custom property in marshel or unmarshal method.*

Is this possible to do this in camel?

please give example if there is way.

My custom dataformat code is as follows


package com.camel.spring.test.dataFormat;

import groovy.xml.MarkupBuilder;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringWriter;
import java.util.HashMap;

import org.apache.camel.Exchange;
import org.apache.camel.spi.DataFormat;
import com.predic8.wsdl.Definitions;
import com.predic8.wsdl.WSDLParser;
import com.predic8.wstool.creator.RequestCreator;
import com.predic8.wstool.creator.SOARequestCreator;

public final class SOAPDataFormat implements DataFormat {

    public void marshal(Exchange exchange, Object dataDefination,
OutputStream stream) throws Exception {
            WSDLParser parser = new WSDLParser();
            Definitions wsdl = parser
                   
.parse("http://localhost:8081/Myservice/services/TestService?wsdl");
            StringWriter writer = new StringWriter();
            HashMap<String, Object> formParams = new HashMap<String,
Object>();
            SOARequestCreator creator = new SOARequestCreator(wsdl,
                    new RequestCreator(), new MarkupBuilder(writer));
            creator.setBuilder(new MarkupBuilder(writer));
            creator.setDefinitions(wsdl);
            creator.setFormParams(formParams);
            creator.setCreator(new RequestCreator());
            creator.createRequest("TestService",
"getApplication","TestServiceHttpBinding");
            stream.write(writer.toString().getBytes());
        }

        public Object unmarshal(Exchange exchange, InputStream stream)
throws Exception {
            return null;
        }
}


*my route configuration is*

<camel:route>
        <from uri="file:d:/inbox/wsJson?noop=true" />
        <marshal >
            <custom ref="soapDataFormat" />
        </marshal>
        <to
uri="cxf://http://localhost:8081/Myservice/services/TestService?wsdlURL=http://localhost:8081//Myservice/services/TestService?wsdl&amp;serviceName={http://service.application.atpl.com}TestService&amp;portName={http://service.application.atpl.com}TestServiceHttpPort&amp;dataFormat=MESSAGE"/>
    </camel:route>


I am just working on marshaling so ignore unmarshal code.

i want to pass
"http://localhost:8081/Myservice/services/TestService?wsdl","TestService",
"getApplication","TestServiceHttpBinding" values runtime that is changed on
request to request basis.

i found 1 work aroung by setting header values, but which is not proper
solution

please help me

Thanks in advance.



--
View this message in context: http://camel.465427.n5.nabble.com/how-to-pass-parameter-to-camel-custom-datafotmat-tp5747098.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message