WSO2 DOCTYPE not allowed calling REST Api - proxy

i m working with this proxy:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="PubMedDataProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<call>
<endpoint>
<http method="get"
uri-template="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi?dbfrom=omim&Mdb=pubmed&id=230900"/>
</endpoint>
</call>
<log level="custom">
<property name="MyLOg" expression="//eLinkResult/DbFrom/text()"/>
</log>
<respond/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<description/>
</proxy>
i get this exception:
TID: [0] [ESB] [2015-05-21 13:45:34,838] ERROR {org.apache.synapse.transport.passthru.util.RelayUtils} - Error while building Passthrough stream {org.apache.synapse.transport.passthru.util.RelayUtils}
org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,142]
Message: DOCTYPE is not allowed
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566)
at org.apache.axis2.builder.ApplicationXMLBuilder.processDocument(ApplicationXMLBuilder.java:81)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:118)
at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:107)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:82)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:68)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:239)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:556)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:198)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:488)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:170)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:225)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,142]
Message: DOCTYPE is not allowed
...
Calling the service in a normal REST client i get the XML result withouth any problem.
The issue occured when the proxy tries to parse the resulting xml. Indeed removing the Log mediator with the property inside the proxy returns the result correctly.
What am i missing?

Add the following to your proxy:
<parameter name="ApplicationXMLBuilder.allowDTD">true</parameter>

Add the below parameter to the axis2.xml file under the <axisconfig name="AxisJava2.0"> also working.
<parameter name="ApplicationXMLBuilder.allowDTD">true</parameter>

Related

Error occurred in the mediation of the class mediator WSO2 ESB

I used wso2 esb 5.0 for create proxy services. I created proxy service using class mediator. Below is the java class.
public class CalculatePaymentAmount extends AbstractMediator {
public boolean mediate(MessageContext messageContext) {
String noOfMonths = messageContext.getEnvelope().getBody().getFirstElement().
getFirstChildWithName(new QName("noOfMonths")).getText();
String InsuranceRate = messageContext.getEnvelope().getBody().getFirstElement().
getFirstChildWithName(new QName("InsuranceRate")).getText();
DecimalFormat decimalFormat = new DecimalFormat("#.##");
double totalAmount = Double.parseDouble(noOfMonths) * Double.parseDouble(InsuranceRate);
messageContext.setProperty("noOfMonths", noOfMonths);
messageContext.setProperty("paymentAmount", decimalFormat.format(totalAmount));
return true;
}
public String getType() {
return null;
}
public void setTraceState(int traceState) {
traceState = 0;
}
public int getTraceState() {
return 0;
}
}
I created the proxy service using class mediator. Below define the proxy code.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="PaymentAmountProxy"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<log/>
<class name="com.mediator.java.CalculatePaymentAmount"/>
<property expression="get-property('default','noOfMonths')"
name="getNoOfMonths"
scope="default"
type="STRING"/>
<property expression="get-property('default','paymentAmount')"
name="getPaymentAmount"
scope="default"
type="STRING"/>
<log>
<property expression="get-property('default','getNoOfMonths')"
name="No.Of Months:"/>
<property expression="get-property('default','getPaymentAmount')"
name="Paymrent Amount:"/>
</log>
</inSequence>
</target>
<description/>
</proxy>
This one working fine and gave expected response.
But when I use this class mediator with other mediators, it getting errors when I invoked the proxy service.
Below mentioned the proxy service that I used with class mediator.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="LatestLicenseRenewalSystem"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<log/>
<property expression="get-property('transport','VehicleNo')"
name="vehicleNo"
scope="default"
type="STRING"/>
<log>
<property expression="get-property('default','vehicleNo')" name="VehicleNo"/>
</log>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:sam="http://sample.esb.org">
<soapenv:Header/>
<soapenv:Body>
<sam:getPolicyID>
<sam:vehicleNumber>$1</sam:vehicleNumber>
</sam:getPolicyID>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="get-property('default','vehicleNo')"/>
</args>
</payloadFactory>
<log level="full"/>
<header name="Action" scope="default" value="urn:getCertificateID"/>
<call>
<endpoint>
<address format="soap12"
uri="http://172.17.0.1:9763/services/EmissionTestService.EmissionTestServiceHttpSoap12Endpoint/">
<enableAddressing/>
</address>
</endpoint>
</call>
<log level="full"/>
<property xmlns:ns="http://sample.esb.org"
expression="//ns:getCertificateIDResponse/ns:return"
name="certificateID"
scope="default"
type="STRING"/>
<log>
<property expression="get-property('default','certificateID')"
name="CertificateID"/>
</log>
<class name="com.mediator.java.CalculatePaymentAmount"/>
<property expression="get-property('default','noOfMonths')"
name="getNoOfMonths"
scope="default"
type="STRING"/>
<property expression="get-property('default','paymentAmount')"
name="getPaymentAmount"
scope="default"
type="STRING"/>
<log>
<property expression="get-property('default','getNoOfMonths')"
name="No.Of Months:"/>
<property expression="get-property('default','getPaymentAmount')"
name="Paymrent Amount:"/>
</log>
<respond/>
</inSequence>
</target>
<description/>
</proxy>
Below error is occurred when invoking the above proxy service.
LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: urn:getCertificateIDResponse, SOAPAction: urn:getCertificateIDResponse, ReplyTo: http://www.w3.org/2005/08/addressing/anonymous, MessageID: urn:uuid:6f4557eb-b8ff-4c19-bbe8-4c7e929d8386, Direction: request, MESSAGE = Executing default 'fault' sequence, ERROR_CODE = 0, ERROR_MESSAGE = Error occured in the mediation of the class mediator, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:Action>urn:getCertificateIDResponse</wsa:Action><wsa:RelatesTo>urn:uuid:6f4557eb-b8ff-4c19-bbe8-4c7e929d8386</wsa:RelatesTo></soapenv:Header><soapenv:Body><ns:getCertificateIDResponse xmlns:ns="http://sample.esb.org"><ns:return>-1250719063</ns:return></ns:getCertificateIDResponse></soapenv:Body></soapenv:Envelope>
Can anyone help me to solve this. Any help or workarounds are really appreciated.
Your class mediator is accessing the elements 'noOfMonths' and 'InsuranceRate' from the message context. But according to the error log, the message context is having a different soap envelope which does not have the above elements.
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:Action>urn:getCertificateIDResponse</wsa:Action><wsa:RelatesTo>urn:uuid:6f4557eb-b8ff-4c19-bbe8-4c7e929d8386</wsa:RelatesTo></soapenv:Header><soapenv:Body><ns:getCertificateIDResponse xmlns:ns="http://sample.esb.org"><ns:return>-1250719063</ns:return></ns:getCertificateIDResponse></soapenv:Body></soapenv:Envelope>
This must me the response received from the call operation before the class mediator.
You have to either isolate the class mediator from the call operation and use different proxy services or move the class mediator above the payload factory.
For solve this issue, use payloadFactory mediator before the class mediator and set the parameters for the payload. I mentioned below the code.
<payloadFactory media-type="xml">
<format>
<paymentDetails xmlns="">
<noOfMonths>$1</noOfMonths>
<InsuranceRate>$2</InsuranceRate>
</paymentDetails>
</format>
<args>
<arg evaluator="xml" expression="get-property('default','noOfMonths')"/>
<arg evaluator="xml" expression="get-property('default','InsuranceRate')"/>
</args>
</payloadFactory>
<class name="com.mediator.java.CalculatePaymentAmount"/>

Search a user in multiple systems through WSO2 ESB proxy

I need to send just one request (can be a proxy url) which takes user id as input and call multiple endpoints and return the response after aggregating all of them.
Currently I am using a proxy service implementation to achieve it but is returns just one response(can be from any of the endpoints) and not able to combine responses from other systems/endpoints. Though I can see the response from another endpoint in my server console.
Below is the code I implemented so far:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="ProxyTestTwoW"
transports="http,https"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log/>
<clone>
<target>
<sequence>
<property name="Application" value="Application1"/>
<property name="messageType"
value="application/xacml+json"
scope="axis2"
type="STRING"/>
<property name="Authorization"
expression="fn:concat('Basic ', base64Encode('username:password'))"
scope="transport"/>
<send>
<endpoint>
<address uri="localhost:8080/iiq/rest/identities/9000070"/>
</endpoint>
</send>
</sequence>
</target>
<target>
<sequence>
<property name="Application" value="Application2"/>
<property name="messageType"
value="application/xacml+json"
scope="axis2"
type="STRING"/>
<property name="Authorization"
expression="fn:concat('Basic ', base64Encode('username:password'))"
scope="transport"/>
<send>
<endpoint>
<address uri="http://localhost:8080/iiq/rest/identities/9000071"/>
</endpoint>
</send>
</sequence>
</target>
</clone>
</inSequence>
<outSequence>
<log level="full" description="">
<property name="Component" expression="get-property('Application')"/>
</log>
<aggregate>
<completeCondition>
<messageCount min="2"/>
</completeCondition>
<onComplete expression="$body/*[1]">
<property name="messageType"
value="application/xacml+json"
scope="axis2"
type="STRING"
description="messageType"/>
<send/>
</onComplete>
</aggregate>
</outSequence>
<faultSequence>
<log level="full" category="WARN"/>
</faultSequence>
</target>
<description/>
</proxy>
Result :
After hitting proxy URL in browser: - Only one response as below:
<jsonObject><viewableIdentityAttributes><Email>Kevin.Mollo#companyb.com</Email><cn>Kevin Mollo</cn><Last Name>Mollo</Last Name><First Name>Kevin</First Name></viewableIdentityAttributes><listAttributes>First Name</listAttributes><listAttributes>Last Name</listAttributes><listAttributes>Email</listAttributes><listAttributes>cn</listAttributes></jsonObject>
In server logs:
[2016-07-14 11:46:35,057] INFO - LogMediator To: http://www.w3.org/2005/08/addr
essing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:3beaaf16-7b94-4e
08-a3e0-7605869572c7, Direction: response, Component = Application1, Payload: {"vi
ewableIdentityAttributes":{"Email":"Kevin.Mollo#companyb.com","cn":"Kevin Mollo"
,"Last Name":"Mollo","First Name":"Kevin"},"assignedRoles":[],"listAttributes":[
"First Name","Last Name","Email","cn"]}
[2016-07-14 11:46:35,057] INFO - LogMediator To: http://www.w3.org/2005/08/addr
essing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:c878c7db-ad4c-49
46-94d6-75aebc75ad8e, Direction: response, Component = Application1, Payload: {"vi
ewableIdentityAttributes":{"Email":"Michelle.Lassauze#companyb.com","cn":"Michel
le Lassauze","Last Name":"Lassauze","First Name":"Michelle"},"assignedRoles":[],
"listAttributes":["First Name","Last Name","Email","cn"]}
As we can see I get responses from both the endpoints in server logs.
As per analysis, I feel to make it work properly and get the responses from both the endpoints, we need change the following:
1. Using call mediator instead of send if we have multiple endpoints to be called.
2. Using enrich mediator to store the responses.
I tried following the above approaches but I am unable to get the expected results as I am not sure how to use enrich mediator in this case.
Please help me in fixing the above issues.
Clone mediator will be used to send identical copies of message to different endpoints.
Iterate mediator will be used to send message chunks of one particular message to different endpoints.
Enrich mediator will be used to change message (Ex: removing content, adding etc.) [1]
Check your endpoints and check whether they provide proper responses to work with aggregate mediator.
I add sample scenario here. You can test that with your ESB pack to understand the above three mediators usage. You just have to start 2 instances of SimpleStockQuote service [2] and publish message to proxy via SOAPUI.
<proxy name="ScatterGatherProxy" startOnLoad="true" trace="disable" transports="https http">
<description/>
<target>
<inSequence>
<clone>
<target>
<sequence>
<send>
<endpoint name="vendorA">
<address uri="http://localhost:9001/services/SimpleStockQuoteService/"/>
</endpoint>
</send>
</sequence>
</target>
<target>
<sequence>
<send>
<endpoint name="vendorB">
<address uri="http://localhost:9002/services/SimpleStockQuoteService/"/>
</endpoint>
</send>
</sequence>
</target>
</clone>
</inSequence>
<outSequence>
<log level="full"/>
<aggregate>
<completeCondition>
<messageCount min="2"/>
</completeCondition>
<onComplete expression="//m0:return"
xmlns:m0="http://services.samples" xmlns:m1="http://services.samples/xsd">
<enrich>
<source clone="true" xpath="//m0:return[not(preceding-sibling::m0:return/m1:last <= m1:last) and not(following-sibling::m0:return/m1:last < m1:last)]"/>
<target type="body"/>
</enrich>
<send/>
</onComplete>
</aggregate>
</outSequence>
</target>
</proxy>
If you need further assistance, please attach more details like responses of your service.
[1] http://dilshanilive.blogspot.com/2016/03/enrich-mediator-wso2-esb.html
[2] https://docs.wso2.com/display/ESB490/Setting+Up+the+ESB+Samples#Starting%20the%20Axis2%20server

Error BlockingMessageSender of message processor in WSO2

I'm trying to use the message forwarding processor in WSO2 (4.8.1).
The context is the follow:
1) I've my messages in a Message Store
2) I use my message forwarding processor to extract messages from the store and invoke a wso2 proxy
3) my proxy invoke an external service
I'm testing the SOAP Fault of my external service.
Here you are my code
My message forwarding processor configuration is the following
<?xml version="1.0" encoding="UTF-8"?><messageProcessor xmlns="http://ws.apache.org/ns/synapse" class="org.apache.synapse.message.processor.impl.forwarder.ScheduledMessageForwardingProcessor" name="AnotherCapForwardMessageProcessor" targetEndpoint="AnotherCapProxyEndPoint" messageStore="OperCupIDStore">
<parameter name="message.processor.reply.sequence">AnotherCapProcessorReply</parameter>
<parameter name="max.delivery.attempts">2</parameter>
<parameter name="client.retry.interval">5000</parameter>
<parameter name="interval">5000</parameter>
<parameter name="message.processor.fault.sequence">AnotherCapProcessorFault</parameter>
<parameter name="is.active">true</parameter>
and my proxy is the following
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="AnotherCapProxy" transports="http https" startOnLoad="true" trace="disable">
<target>
<inSequence>
<log level="custom">
<property name="where" value="********** [ANOTHER-CAP-PROXY] - BEGINNING OF IN SEQUENCE .... "/>
</log>
<log level="full">
<property name="what" value="********** [ANOTHER-CAP-PROXY] - MESSAGE FROM OPERCUPIDSTORE...."/>
</log>
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="false" scope="default" type="STRING"/>
<property name="OUT_ONLY" value="false" scope="default" type="STRING"/>
<property name="InternalCodErr" value="WSO2_xxx" scope="default" type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:p="http://gamopera.ifpl.csi.it" name="ProcessingID" expression="//p:id" scope="default" type="STRING"/>
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="what" expression="fn:concat('****[ANOTHER-CAP-PROXY] - PROCESSING ID: ',get-property('default','ProcessingID'))"/>
</log>
<xslt xmlns:ns="http://org.apache.synapse/xsd" key="gov:xslt/getInputCUPXml_Transform.xslt" source="$body">
<property name="idOp" expression="get-property('default','ProcessingID')"/>
</xslt>
<log level="full">
<property name="what" value="********** [ANOTHER-CAP-PROXY] - CALLING GAMOPERA FOR THE XML REQUEST TO INVOKE SIMON.... "/>
</log>
<header name="Action" scope="default" value=" "/>
<send>
<endpoint key="AnotherCapGamoperaCreateXMLServiceEndpoint"/>
</send>
</inSequence>
<outSequence>
<log level="full">
<property name="where" value="********** [ANOTHER-CAP-PROXY] - BEGINNING OF OUT SEQUENCE .... "/>
<property name="where" value="********** [ANOTHER-CAP-PROXY] - THE GAMOPERA RESPONSE ...."/>
</log>
<filter xmlns:s12="http://www.w3.org/2003/05/soap-envelope" xmlns:ns="http://org.apache.synapse/xsd" xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xpath="s11:Body/s11:Fault | s12:Body/s12:Fault">
<then>
<property name="ErrorCode" value="WSO2_004" scope="operation" type="STRING"/>
<log level="custom">
<property name="where" value="********** [ANOTHER-CAP-PROXY] - SOAP FAULT !!! SOMETHING WENT WRONG CALLING GAMOPERA IN GETTING XML ...."/>
<property name="ERROR_CODE" expression="get-property('operation','ErrorCode')"/>
</log>
</then>
<else>
<property name="ErrorCode" value="WSO2_003" scope="default" type="STRING"/>
<log level="custom">
<property name="where" value="********** [ANOTHER-CAP-PROXY] - NOT COMPLETE RESPONSE FROM GAMOPERA IN GETTING XML ..."/>
<property name="ERROR_CODE = " expression="get-property('default','ErrorCode')"/>
</log>
</else>
</filter>
<send/>
</outSequence>
<faultSequence>
<log level="full">
<property name="where" value="********** [ANOTHER-CAP-PROXY] - BEGINNING OF FAULT SEQUENCE .... "/>
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
<property name="ERROR_DETAIL" expression="get-property('ERROR_DETAIL')"/>
<property name="ERROR_EXCEPTION" expression="get-property('ERROR_EXCEPTION')"/>
</log>
<send/>
</faultSequence>
</target>
<publishWSDL key="gov:wsdl/AnotherWSDL.wsdl"/>
So my message processor try two times, then deactive itself.
When execute the log is the follow ...
TID: [0] [ESB] [2014-10-31 11:00:17,128] INFO {org.apache.synapse.mediators.builtin.LogMediator} - where = ********** [ANOTHER-CAP-PROXY] - BEGINNING OF IN SEQUENCE .... {org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [ESB] [2014-10-31 11:00:17,128] INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: /wso003/services/AnotherCapProxy, WSAction: urn:process, SOAPAction: urn:process, MessageID: urn:uuid:2262a521-97da-471a-8691-da9016cbeac3, Direction: request, what = ********** [ANOTHER-CAP-PROXY] - MESSAGE FROM OPERCUPIDSTORE...., Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>
<gam:process xmlns:gam="http://gamopera.ifpl.csi.it">
<!--Zero or more repetitions:-->
<gam:id>459</gam:id></gam:process>
</soapenv:Body></soapenv:Envelope> {org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [ESB] [2014-10-31 11:00:17,129] INFO {org.apache.synapse.mediators.builtin.LogMediator} - what = ****[ANOTHER-CAP-PROXY] - PROCESSING ID: 459 {org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [ESB] [2014-10-31 11:00:17,132] INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: /wso003/services/AnotherCapProxy, WSAction: urn:process, SOAPAction: urn:process, MessageID: urn:uuid:2262a521-97da-471a-8691-da9016cbeac3, Direction: request, what = ********** [ANOTHER-CAP-PROXY] - CALLING GAMOPERA FOR THE XML REQUEST TO INVOKE SIMON.... , Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>
<p:gestWso2GetInputCUPXml xmlns:p="http://operintegrated.interfacews.operserv.gamopera.csi.it/"><input><idOperazione>459</idOperazione></input></p:gestWso2GetInputCUPXml></soapenv:Body></soapenv:Envelope> {org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [ESB] [2014-10-31 11:00:18,980] INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:bf5762a3-2324-4fed-8b56-fdc7cdd4cac2, Direction: response, where = ********** [ANOTHER-CAP-PROXY] - BEGINNING OF OUT SEQUENCE .... , where = ********** [ANOTHER-CAP-PROXY] - THE GAMOPERA RESPONSE ...., Envelope: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Errore imprevisto occorso durante l'esecuzione del metodo:java.lang.NullPointerException</faultstring><detail><ns1:Exception xmlns:ns1="http://operintegrated.interfacews.operserv.gamopera.csi.it/"></ns1:Exception></detail></soap:Fault></soap:Body></soap:Envelope> {org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [ESB] [2014-10-31 11:00:18,980] INFO {org.apache.synapse.mediators.builtin.LogMediator} - where = ********** [ANOTHER-CAP-PROXY] - FAULT !!! SOMETHING WENT WRONG CALLING GAMOPERA IN GETTING XML ...., ERROR_CODE = WSO2_004 {org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [ESB] [2014-10-31 11:00:18,985] ERROR {org.apache.synapse.message.processor.impl.forwarder.ForwardingService} - BlockingMessageSender of message processor [AnotherCapForwardMessageProcessor] failed to send message to the endpoint {org.apache.synapse.message.processor.impl.forwarder.ForwardingService}
TID: [0] [ESB] [2014-10-31 11:00:18,986] INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: /wso003/services/OperCupPrepareProxy.OperCupPrepareProxyHttpSoap11Endpoint, WSAction: urn:process, SOAPAction: urn:process, MessageID: urn:uuid:4ECFA324C9FBB675AB842060829710186-582880576, Direction: request, where = ********** [ANOTHER-CAP-PROCESSOR-FAULT] - BEGINNING PROCESSOR FAULT SEQUENCE .... , Envelope: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Errore imprevisto occorso durante l'esecuzione del metodo:java.lang.NullPointerException</faultstring><detail><ns1:Exception xmlns:ns1="http://operintegrated.interfacews.operserv.gamopera.csi.it/"></ns1:Exception></detail></soap:Fault></soap:Body></soap:Envelope> {org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [ESB] [2014-10-31 11:00:18,992] INFO {org.apache.synapse.message.processor.impl.ScheduledMessageProcessor} - Successfully deactivated the message processor [AnotherCapForwardMessageProcessor] {org.apache.synapse.message.processor.impl.ScheduledMessageProcessor}
I see that the execution doesn't cross in the message processor retry sequence and probably something goes wrong when i close the proxy out sequence.
Any suggestion? Thank you very much in advance!!!
Bye
Cesare
When you send back the soap fault to the message processor in your proxy outSequence, the message processor execute it's fault sequence : HTTP Status code of your message must have a value different from '500'. You should log it (use property $axis2:HTTP_SC)
When the fault sequence is executed 'max.delivery.attempts' times, the message processor is deactivated, if you want it to redeliver the message indefinitely, set this value to -1

Role based access control to WSO Message Broker Hierarchical Topic

I've recently started experimenting with a Message exchange between WSO2 ESB's via WSO2's MB for a requirement. Created a JMS sender Proxy Service which concatenates endpoint URL based on SOAP Input (used Header property and defaultEndpoint).
On Message Broker:
Have set up a Hierarchical topic as
Root|
Node1
Node2
With 3 users and their specific roles as Root, Node1, Node2. Requirement is Node 1 should be able to subscribe for both Node 1 and Root, Similarly for Node2, Only Node2 and Root.
The problem is When creating a proxy service subscriber can only set it to subscribe one Node only (Root or Node1 or Node2). Tried setting destination as Root.# but then All Nodes are subscribed (even when Node USer is not set to Subscribe the other based on Role based Topic access). Following is the code for subscriber
enter code here
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="Subscriber_Node2"
transports="jms"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="OUT_ONLY" value="true"/>
<log level="full"/>
<log level="custom" separator="###">
<property name="STATE"
value="**************** RECEIVED AT Node 2 ***************"/>
</log>
<drop/>
</inSequence>
<outSequence/>
<faultSequence>
<log level="custom">
<property name="text" value="An unexpected error occured"/>
<property name="message" expression="get-property('ERROR_MESSAGE')"/>
<property name="code" expression="get-property('ERROR_CODE')"/>
<property name="detail" expression="get-property('ERROR_DETAIL')"/>
<property name="exception" expression="get-property('ERROR_EXCEPTION')"/>
</log>
</faultSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="java.naming.factory.initial">
org.wso2.andes.jndi.PropertiesFileInitialContextFactory
</parameter>
<parameter name="transport.jms.ConnectionFactory">
Store2TopicConnectionFactory</parameter>
<parameter name="java.naming.provider.url">
repository/conf/jndi.properties</parameter>
<parameter name="transport.jms.DestinationType">topic</parameter>
<parameter name="transport.jms.Destination">HQ.Store_2</parameter>
<description/>
</proxy>
jndi.properties:
connectionfactory.Node1TopicConnectionFactory = amqp://Node1:Node1#clientID/carbon?
brokerlist='tcp://localhost:5680'
connectionfactory.Node2TopicConnectionFactory = amqp://Node2:Node2#clientID/carbon?
brokerlist='tcp://localhost:5680'
connectionfactory.RootTopicConnectionFactory = amqp://Root1:Root1#clientID/carbon?
brokerlist='tcp://localhost:5680'
topic.Root = Root
topic.Root.Node1 = Root.Node1
topic.Root.Node2 = Root.Node2
Is there a way a Subscriber can subscribe to Multiple Topics in a hierrarchy and its access be controlled by User and Role?

Having trouble with content based routing in Camel with a CXFRS endpoint and xPath

I am trying to create a route that is determined by the content in the REST payload using xPath. I have been successful in using routing based on the message header:
<when>
<simple>${headers.operationName} == 'createContainerOutput'</simple>
<bean ref="containerOutputProcessor"/>
</when>
which properly invokes the containerOutputProcessor...
but for this xPath route:
<when>
<xpath>/*[local-name()='order-request']/#type='TrayOutput'</xpath>
<bean ref="containerOutputProcessor"/>
</when>
I get the the exception:
org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.w3c.dom.Document with value [com.mmi.ws.ContainerOutputOrderRequest#6290dc]
for this payload
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order-request type="TrayOutput">
<parameter name="orderName">Example Tray Output Order</parameter>
<parameter name="enableScan">true</parameter>
<parameter name="autoStart">false</parameter>
<parameter name="priority">3</parameter>
<item barcode="23990001"/>
<item barcode="23990002"/>
</order-request>
Is this type of routing a good idea? Is there a better way to route based on what type of order-request is being submitted?
Thanks for any help/guidance you may have for me!
Here is the complete context
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<!-- enable Spring #Component scan -->
<context:component-scan base-package="com.mmi.ws"/>
<!-- web service beans -->
<bean id="containerOutputWS" class="com.mmi.ws.service.impl.ContainerOutputWSImpl" />
<bean id="containerTypesWS" class="com.mmi.ws.service.impl.ContainerTypesWSImpl" />
<!-- processor beans -->
<bean id="containerOutputProcessor" class="com.mmi.ws.service.ContainerOutputProcessor" />
<bean id="containerTypesProcessor" class="com.mmi.ws.service.ContainerTypesProcessor" />
<bean id="unsupportedPathProcessor" class="com.mmi.ws.service.UnsupportedPathProcessor" />
<!-- Define the real JAXRS back end service -->
<jaxrs:server id="restService"
address="http://localhost:9998/sc"
staticSubresourceResolution="true">
<jaxrs:serviceBeans>
<ref bean="containerOutputWS"/>
<ref bean="containerTypesWS"/>
</jaxrs:serviceBeans>
</jaxrs:server>
<!-- define the restful server and client endpoints -->
<cxf:rsServer id="rsServer" address="http://localhost:9999/sc" loggingFeatureEnabled="true" loggingSizeLimit="20">
<cxf:serviceBeans >
<ref bean="containerOutputWS"/>
<ref bean="containerTypesWS"/>
</cxf:serviceBeans>
</cxf:rsServer>
<cxf:rsServer id="rsClient" address="http://localhost:9998/sc" loggingFeatureEnabled="true" loggingSizeLimit="20">
<cxf:serviceBeans >
<ref bean="containerOutputWS"/>
<ref bean="containerTypesWS"/>
</cxf:serviceBeans>
</cxf:rsServer>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<!--
any classes in the below 'packageScan'packages that extends RouteBuilder
will be added as a camel route. At least one route is required to start the cxf web service
-->
<packageScan>
<package>com.mmi.ws</package>
</packageScan>
<dataFormats>
<xstream id="xstream-utf8" encoding="UTF-8"/>
<xstream id="xstream-default"/>
</dataFormats>
<!-- route starts from the cxf webservice -->
<route streamCache="true">
<from uri="cxfrs://bean://rsServer"/>
<log message="XML payload to send to REST WS:${body}" />
<setHeader headerName="CamelCxfRsUsingHttpAPI"><constant>True</constant> </setHeader>
<choice>
<when>
<simple>${headers.operationName} == 'getContainers'</simple>
<bean ref="containerTypesProcessor"/>
</when>
<when>
<xpath>/*[local-name()='order-request']/#type='TrayOutput'</xpath>
<bean ref="containerOutputProcessor"/>
</when>
<otherwise>
<bean ref="unsupportedPathProcessor"/>
<to uri="cxfrs://bean://rsClient"/>
</otherwise>
</choice>
</route>
</camelContext>
</beans>
and the web service class:
#Path("/container/output/")
public class ContainerOutputWSImpl
{
#POST
#Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
#Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ContainerOutputView createContainerOutput(ContainerOutputOrderRequest containerOutput) {
// TODO Auto-generated method stub
return new ContainerOutputView();
}
}
and finally, the xml payload and error stack:
Address: http://localhost:9999/sc/container/output/
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: application/xml
Headers: {accept-encoding=[gzip,deflate], connection=[keep-alive], Content-Length=[384], content-type=[application/xml], Host=[localhost:9999], User-Agent=[Apache-HttpClient/4.1.1 (java 1.5)]}
Payload: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order-request type="TrayOutput">
<parameter name="orderName">Example Tray Output Order</parameter>
<parameter name="enableScan">true</parameter>
<parameter name="autoStart">false</parameter>
<parameter name="priority">3</parameter>
<item barcode="23990001"/>
<item barcode="23990002"/>
</order-request>
--------------------------------------
[ERROR] 2013-02-07 17:53:37.059 [qtp27633254-28: DefaultErrorHandler] Failed delivery for (MessageId: ID-PWY-EHANSEN-3070-1360288389778-0-2 on ExchangeId: ID-PWY-EHANSEN-3070-1360288389778-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.RuntimeCamelException: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.w3c.dom.Document with value [com.mmi.ws.ContainerOutputOrderRequest#9fbbe5]
org.apache.camel.RuntimeCamelException: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.w3c.dom.Document with value [com.mmi.ws.ContainerOutputOrderRequest#9fbbe5]
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1271)
at org.apache.camel.builder.xml.XPathBuilder.getDocument(XPathBuilder.java:1027)
at org.apache.camel.builder.xml.XPathBuilder.doInEvaluateAs(XPathBuilder.java:850)
at org.apache.camel.builder.xml.XPathBuilder.evaluateAs(XPathBuilder.java:757)
at org.apache.camel.builder.xml.XPathBuilder.matches(XPathBuilder.java:145)
at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:66)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:334)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)
at org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.asyncInvoke(CxfRsInvoker.java:87)
at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.performInvocation(CxfRsInvoker.java:57)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:201)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:102)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:355)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:319)
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1074)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1010)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:722)
Before the content based router, you can convert the message to take out the payload from the internal CXF list. There is a trick with the simple language to grab the first index from the list:
<transform>
<simple>${body[0]}</simple>
</transform>
<choice>
...
Do you have camel-jaxb on the classpath. If so it may work out of the box without that trick. Not sure though, as CXF is a bit special. Also dependes on what version of Camel / CXF you use. You should really mention this when you ask questions!

Resources