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橪;serviceName={http://service.application.atpl.com}TestService橪;portName={http://service.application.atpl.com}TestServiceHttpPort橪;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.
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橪;serviceName={http://service.application.atpl.com}TestService橪;portName={http://service.application.atpl.com}TestServiceHttpPort橪;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.