I hvae written camel route which is doing following.
Step 1: Web service is consuming TCAUpdate object
Step 2: This object is marshelled to JSON object using jackson library
Step 3: This generated JSON is stored in one file
*UpdateTCA.java*
public class UpdateTCA {
int id;
String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
*UpdateTCAImpl.java*
@WebService(endpointInterface = "com.IUpdateTCA")
public class UpdateTCAImpl implements IUpdateTCA {
public UpdateTCA getTCA(UpdateTCA tca) {
return tca;
}
}
*camel-context.xml*
<camelContext id="tcaContext"
xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
<json id="jack" library="Jackson"
unmarshalTypeName="com.UpdateTCAImpl"/>
</dataFormats>
<route id="tcaRoute">
* <from uri="cxf:bean:soapTCAEndpoint" />
<marshal ref="jack" />
<to uri="file:src/main/resources/out.txt" />*
</route>
</camelContext>
<cxf:cxfEndpoint id="soapTCAEndpoint"
address="http://localhost:9090/services/UpdateTCAService"
endpointName="s:soapTCAEndpoint"
serviceName="s:testTargetWebService"
serviceClass="com.UpdateTCAImpl"
xmlns:s="http://server.webservice.cxf.dlcc.xyz.com/">
<cxf:properties>
<entry key="dataFormat" value="POJO" />
</cxf:properties>
</cxf:cxfEndpoint>
Output of above route is as follows
[{"id":1,"name":"abc"}]
*Question 1 : *
How can I make output to [{ "Data":{"id":1,"name":"abc"} }]
So instead of [{"id":1,"name":"abc"}] , I should get
[*{"Data":*{"id":1,"name":"abc"}*}*]
Note : One option is to create separate class Data and put UpdateTCA as
instance variable in that. But I dont want to add one more extra class.
*Question 2 :* HOw can I generate output which doesn't have starting and
ending square brace []. So output should look like
So instead of [{"id":1,"name":"abc"}] , I should get {"id":1,"name":"abc"}
--
View this message in context:
http://camel.465427.n5.nabble.com/Issue-with-output-format-from-POJO-to-JSON-marshalling-tp5731792.html
Sent from the Camel - Users mailing list archive at Nabble.com.