WSO2 EI 6.3.0 Log Error while loading the registry resource - wso2

I have a proxy in WSO2 Enterprise Integrator 6.3.0 with endpoint configured in conf registry. Sometimes I receive errors in this proxy with message in LOG:
[2018-09-12 09:33:22,542] [-1234] [] [SynapseWorker-11] ERROR {org.apache.synapse.config.xml.endpoints.LoadbalanceEndpointFactory} - Invalid endpoint configuration.
[2018-09-12 09:33:22,542] [-1234] [] [SynapseWorker-11] WARN {org.apache.synapse.config.SynapseConfiguration} - Error while loading the resource conf:services/corp/servicev1/endpoint/ERPEndpoint.xml from the remote registry. Previously cached value will be used. Check the registry accessibility.
[2018-09-12 09:33:22,545] [-1234] [] [SynapseWorker-11] INFO {org.apache.axis2.transport.http.HTTPSender} - Unable to sendViaPost to url[http://...address ommited...]
java.net.SocketException: Connection reset
It seems to me it doesn't catch the endpoint of registry or cache.
PS: In my registry the address endpoint is with dns name and when this error occurs the address endpoint appears with IP address.
How to fix this?
Below the sequence and endpoint:
<sequence name="PessoaService_inserirPessoaFisicaNacionalV1_MessageProcessorSequence" onError="PessoaService_GenericFaultHandlerSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property name="PROXY_NAME" scope="default" type="STRING" value="PessoaService_inserirPessoaFisicaNacionalV1_LocalProxy"/>
<property name="SERVICE_VERSION" scope="default" type="STRING" value="1.0"/>
<property expression="$header/wsa:MessageID" name="MessageIdConsumidor" scope="default" type="STRING" xmlns:wsa="http://www.w3.org/2005/08/addressing"/>
<property expression="$header/ns:ApplicationName" name="applicationName" scope="default" type="STRING" xmlns:ns="https://ws.apache.org/axis2"/>
<log level="custom">
<property name="PessoaService_inserirPessoaFisicaNacionalV1_MessageProcessorSequence" value="Started"/>
</log>
<enrich>
<source clone="true" type="envelope"/>
<target property="BODY_ORIGINAL" type="property"/>
</enrich>
<dblookup>
<connection>
<pool>
<dsName>ESB</dsName>
</pool>
</connection>
<statement>
<sql>
<![CDATA[select codigo_configuracao, cnpj_empresa from esb.codigo_configuracao where aplicacao = ? and tipo_pessoa = 'fisica']]>
</sql>
<parameter expression="get-property('applicationName')" type="CHAR"/>
<result column="codigo_configuracao" name="codigo_configuracao"/>
<result column="cnpj_empresa" name="cnpj_empresa"/>
</statement>
</dblookup>
<log level="custom">
<property expression="$ctx:codigo_configuracao" name="PessoaService_inserirPessoaFisicaNacionalV1 [codigo_configuracao]"/>
<property expression="$ctx:cnpj_empresa" name="PessoaService_inserirPessoaFisicaNacionalV1 [cnpj_empresa]"/>
<property expression="get-property('applicationName')" name="PessoaService_inserirPessoaFisicaNacionalV1 [applicationName]"/>
</log>
<call-template target="PessoaService_LoginTemplate">
<with-param name="username" value="username"/>
<with-param name="password" value="pass"/>
<with-param name="companyHandle" value="-1"/>
<with-param name="branchHandle" value="-1"/>
</call-template>
<xslt key="conf:services/corp/pessoaservicev1/transformation/InserirPessoaFisicaNacionalRequest_IntegrarRequestTransformation.xslt">
<property expression="$ctx:AuthenticationTokenId" name="AuthenticationTokenId"/>
<property expression="$ctx:cnpj_empresa" name="cnpjEmpresa"/>
<property expression="$ctx:codigo_configuracao" name="codigoConfiguracao"/>
</xslt>
<log level="custom">
<property expression="$body" name="PessoaService_inserirPessoaFisicaNacionalV1_MessageProcessorSequence [request ERP]"/>
</log>
<enrich>
<source clone="true" type="body"/>
<target property="RequestERP" type="property"/>
</enrich>
<header action="remove" name="Action" scope="default"/>
<header name="Action" scope="default" value="http://.com.br/corporativo/PessoaService/Pessoa/Integrar"/>
<property expression="get-property('registry', 'conf:services/corp/pessoaservicev1/parameters/endpointCallback.properties')" name="endpointCallback" scope="default" type="STRING"/>
<payloadFactory media-type="xml">
<format>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Action>$1</wsa:Action>
<wsa:ReplyTo>
<wsa:Address>$2</wsa:Address>
</wsa:ReplyTo>
<wsa:MessageID>$3</wsa:MessageID>
</soap:Header>
<soap:Body>$4</soap:Body>
</soap:Envelope>
</format>
<args>
<arg value="http://.com.br/corporativo/PessoaService/Pessoa/Integrar"/>
<arg evaluator="xml" expression="$ctx:endpointCallback"/>
<arg evaluator="xml" expression="get-property('MessageID')"/>
<arg evaluator="xml" expression="$body/pes:Integrar" xmlns:pes="http://.com.br/corporativo/PessoaService"/>
</args>
</payloadFactory>
<call blocking="true">
<endpoint key="conf:services/corp/pessoaservicev1/endpoint/ERPEndpoint.xml"/>
</call>
<log level="custom">
<property expression="$body" name="PessoaService_inserirPessoaFisicaNacionalV1_MessageProcessorSequence [ERP Response]"/>
</log>
<filter xmlns:ns="http://.com.br/corporativo/PessoaService" xpath="$body//ns:CodigoRetorno = 'ProcessamentoOK'">
<then>
<call-template target="PessoaService_LogoutTemplate">
<with-param name="AuthenticationTokenId" value="{$ctx:AuthenticationTokenId}"/>
</call-template>
</then>
<else>
<call-template target="PessoaService_LogoutTemplate">
<with-param name="AuthenticationTokenId" value="{$ctx:AuthenticationTokenId}"/>
</call-template>
<property expression="get-property('ReplyTo')" name="uri.var.full" scope="default" type="STRING"/>
<log level="custom">
<property expression="get-property('ReplyTo')" name="PessoaService_inserirPessoaFisicaNacionalV1_MessageProcessorSequence [Processamento NOK - callback endpoint]"/>
</log>
<call>
<endpoint key="conf:services/corp/pessoaservicev1/endpoint/CallbackDynamicEndpoint.xml"/>
</call>
</else>
</filter>
<payloadFactory media-type="xml">
<format>
<p:insert_smart_proxy_operation xmlns:p="http://ws.wso2.org/dataservice">
<p:message_id>$1</p:message_id>
<p:correlation_id>$2</p:correlation_id>
<p:to_address/>
<p:reply_address>$3</p:reply_address>
<p:message>$4</p:message>
<p:status>OK</p:status>
<p:data_processamento>$5</p:data_processamento>
<p:relates_to>$2</p:relates_to>
</p:insert_smart_proxy_operation>
</format>
<args>
<arg evaluator="xml" expression="get-property('MessageID')"/>
<arg evaluator="xml" expression="get-property('MessageIdConsumidor')"/>
<arg evaluator="xml" expression="get-property('endpointCallback')"/>
<arg evaluator="xml" expression="$ctx:RequestERP/*"/>
<arg evaluator="xml" expression="get-property('SYSTEM_DATE')"/>
</args>
</payloadFactory>
<log level="custom">
<property expression="$body" name="PessoaService_inserirPessoaFisicaNacionalV1 [SmartProxy Request]"/>
</log>
<header name="Action" scope="default" value="urn:insert_smart_proxy_operation"/>
<send>
<endpoint key="conf:services/corp/pessoaservicev1/endpoint/SmartProxyDSSEndpoint.xml"/>
</send>
</sequence>
Content of endpoint ERPEndpoint.xml in sequence above:
<endpoint name="BennerERPEndpoint" xmlns="http://ws.apache.org/ns/synapse">
<address uri="http://host/App_Services/PESSOAS/Service.svc/ws">
<enableAddressing/>
<timeout>
<duration>30000</duration>
<responseAction>fault</responseAction>
</timeout>
</address>
</endpoint>

Related

Sometimes receiving:" Error while performing the callout operation" when using callout mediator in a proxy

Sometimes when I am using Callout mediator I am receiving this message specially if I have made previous calls/callouts before in the sequence.
This is the message I receive: ERROR_CODE = 0, ERROR_MESSAGE = Error while performing the callout operation.
This specially occurs when using chaining within proxies.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="InsChildCustomer"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full" separator=", ***********Incoming###########"/>
<property name="originalMessage"
expression="$body"
scope="default"
type="OM"/>
<property xmlns:cus="http://www.example.org/customerWSO2/"
name="SNIPPMessage"
expression="$body/cus:insertChildCustToNSRequest"
scope="default"
type="OM"/>
<sequence key="conf:/resources/sequences/InsChildCustomerHeaderSeq.xml"/>
<filter xmlns:cus="http://www.example.org/customerWSO2/"
source="boolean(//cus:insertChildCustToNSRequest/cus:childCustData/cus:customerContacts/cus:customerContact[1]/cus:email)"
regex="true">
<then>
<property name="customerContacts"
expression="//cus:insertChildCustToNSRequest/cus:childCustData/cus:customerContacts"
scope="default"
type="OM"/>
</then>
<else>
<property name="noContacts" value="1" scope="default" type="INTEGER"/>
</else>
</filter>
<header name="Action" scope="default" value="addList"/>
<payloadFactory media-type="xml">
<format>
<addressbook xmlns=""
xmlns:platformCommon="urn:common_2015_1.platform.webservices.NS.com"
xmlns:listRel="urn:relationships_2015_1.lists.webservices.NS.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:platformCore="urn:core_2015_1.platform.webservices.NS.com"
xsi:type="listRel:CustomerAddressbook">
<defaultBilling>$1</defaultBilling>
<defaultShipping>$2</defaultShipping>
<addressbookAddress xsi:type="platformCommon:Address">
<addr1>$3</addr1>
<addr2>$4</addr2>
<addr3>$5</addr3>
<customFieldList>
<customField scriptId="custrecord_addr_4"
xsi:type="platformCore:StringCustomFieldRef">
<value>$6</value>
</customField>
</customFieldList>
<city>$7</city>
<state>$8</state>
<zip>$9</zip>
<country>$10</country>
</addressbookAddress>
</addressbook>
</format>
<args>
<arg evaluator="xml" expression="//cus:billingaddressindicator/text()"/>
<arg evaluator="xml" expression="//cus:shippingaddressindicator/text()"/>
<arg evaluator="xml" expression="//cus:addr1/text()"/>
<arg evaluator="xml" expression="//cus:addr2/text()"/>
<arg evaluator="xml" expression="//cus:addr3/text()"/>
<arg evaluator="xml" expression="//cus:custrecord_addr_4/text()"/>
<arg evaluator="xml" expression="//cus:city/text()"/>
<arg evaluator="xml" expression="//cus:state/text()"/>
<arg evaluator="xml" expression="//cus:zip/text()"/>
<arg evaluator="xml" expression="//cus:country/text()"/>
</args>
</payloadFactory>
<send>
<endpoint key="conf:/resources/endpoints/NSEndpoint.xml"/>
</send>
</inSequence>
<outSequence>
<header xmlns:platformMsgs="urn:messages_2015_1.platform.webservices.NS.com"
name="platformMsgs:documentInfo"
scope="default"
action="remove"/>
<property xmlns:platformMsgs="urn:messages_2015_1.platform.webservices.NS.com"
xmlns:platformCore="urn:core_2015_1.platform.webservices.NS.com"
name="isSuccess"
expression="//addListResponse/platformMsgs:writeResponseList/platformMsgs:writeResponse/platformCore:status/#isSuccess"
scope="default"
type="STRING"/>
<filter xmlns:platformMsgs="urn:messages_2015_1.platform.webservices.NS.com"
xmlns:platformCore="urn:core_2015_1.platform.webservices.NS.com"
source="//addListResponse/platformMsgs:writeResponseList/platformMsgs:writeResponse/platformCore:status/#isSuccess"
regex="true">
<then>
<log level="full" separator=", *******before_iterator********"/>
<property name="customerInternalId"
expression="//addListResponse/platformMsgs:writeResponseList/platformMsgs:writeResponse/platformMsgs:baseRef/#internalId"
scope="default"
type="STRING"/>
<header name="platformMsgs:platformMsgs:documentInfo"
scope="default"
action="remove"/>
<property name="type"
expression="//addListResponse/platformMsgs:writeResponseList/platformMsgs:writeResponse/platformMsgs:baseRef/#type"
scope="default"
type="STRING"/>
<payloadFactory media-type="xml">
<format>
<urn:get xmlns:urn="urn:messages_2015_1.platform.webservices.NS.com"
xmlns:urn1="urn:core_2015_1.platform.webservices.NS.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<urn:baseRef internalId="$1" type="customer" xsi:type="urn1:RecordRef">
<urn1:name/>
</urn:baseRef>
</urn:get>
</format>
<args>
<arg evaluator="xml" expression="get-property('customerInternalId')"/>
</args>
</payloadFactory>
<header name="Action" scope="default" value="get"/>
<sequence key="conf:resources/sequences/customerAddPassport.xml"/>
<sequence key="conf:resources/sequences/customerAddPreferences.xml"/>
<callout endpointKey="conf:/resources/endpoints/NSEndpoint.xml">
<endpoint name="NSEndpoint">
<address uri="https://webservices.sandbox.NS.com/services/NSPort_2015_1"/>
</endpoint>
<source type="envelope"/>
<target xpath="$body/*"/>
</callout>
<property xmlns:ns="urn:messages_2015_1.platform.webservices.NS.com"
xmlns:listRel="urn:relationships_2015_1.lists.webservices.NS.com"
name="customerEntityId"
expression="//ns:getResponse/ns:readResponse/ns:record/listRel:entityId"
scope="default"
type="STRING"/>
<log level="full" separator=", After_Get"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<payloadFactory media-type="xml">
<format>
<cus:insertChildCustToNSRequest xmlns:cus="http://www.example.org/customerWSO2/">$1
<cus:transactionid>$2</cus:transactionid>
<InternalID xmlns="">$3</InternalID>
</cus:insertChildCustToNSRequest>
</format>
<args>
<arg xmlns:cus="http://www.example.org/customerWSO2/"
evaluator="xml"
expression="$ctx:SNIPPMessage//cus:childCustData"/>
<arg xmlns:cus="http://www.example.org/customerWSO2/"
evaluator="xml"
expression="$ctx:SNIPPMessage//cus:transactionid"/>
<arg evaluator="xml" expression="get-property('customerInternalId')"/>
</args>
</payloadFactory>
<header xmlns:urn="urn:messages_2015_1.platform.webservices.NS.com"
name="urn:passport"
scope="default"
action="remove"/>
<header xmlns:urn="urn:messages_2015_1.platform.webservices.NS.com"
name="urn:preferences"
scope="default"
action="remove"/>
<log level="full" separator=", before SNIPP CALL"/>
<call>
<endpoint key="conf:/resources/endpoints/Teacher.QEndpoint.xml"/>
</call>
<property name="OUT_ONLY" value="false" scope="default" type="STRING"/>
<property name="DISABLE_CHUNKING"
value="false"
scope="axis2"
type="STRING"/>
<property name="messageType" value="text/xml" scope="axis2" type="STRING"/>
<property name="ContentType" value="text/xml" scope="axis2" type="STRING"/>
<filter source="get-property('noContacts')" regex="1">
<then>
<log level="full" separator=", *******without_contacts********"/>
<enrich>
<source type="inline" clone="true">
<insertChildCustToNSResponse xmlns="">
<Type/>
<Status/>
<CustomerInternalId/>
<CustomerEntityId/>
<ContactInternalId>N.A.</ContactInternalId>
</insertChildCustToNSResponse>
</source>
<target type="body"/>
</enrich>
<enrich>
<source type="property" clone="true" property="type"/>
<target xpath="//insertChildCustToNSResponse/Type"/>
</enrich>
<enrich>
<source type="property" clone="true" property="isSuccess"/>
<target xpath="//insertChildCustToNSResponse/Status"/>
</enrich>
<enrich>
<source type="property" clone="true" property="customerInternalId"/>
<target xpath="//insertChildCustToNSResponse/CustomerInternalId"/>
</enrich>
<enrich>
<source type="property" clone="true" property="customerEntityId"/>
<target xpath="//insertChildCustToNSResponse/CustomerEntityId"/>
</enrich>
</then>
<else>
<log level="full" separator=", *******with_contacts********"/>
<drop/>
</else>
</filter>
</then>
<else>
<log level="full" separator=", From false###########"/>
<property name="errorCode"
expression="//addListResponse/platformMsgs:writeResponseList/platformMsgs:writeResponse/platformCore:status/platformCore:statusDetail/platformCore:code"
scope="default"
type="STRING"/>
<property name="errorMessage"
expression="//addListResponse/platformMsgs:writeResponseList/platformMsgs:writeResponse/platformCore:status/platformCore:statusDetail/platformCore:message"
scope="default"
type="STRING"/>
<enrich>
<source type="inline" clone="true">
<insertChildCustToNSResponse xmlns="">
<Status/>
<ErrorCode/>
<ErrorMessage/>
</insertChildCustToNSResponse>
</source>
<target type="body"/>
</enrich>
<enrich>
<source type="property" clone="true" property="isSuccess"/>
<target xpath="//insertChildCustToNSResponse/Status"/>
</enrich>
<enrich>
<source type="property" clone="true" property="errorCode"/>
<target xpath="//insertChildCustToNSResponse/ErrorCode"/>
</enrich>
<enrich>
<source type="property" clone="true" property="errorMessage"/>
<target xpath="//insertChildCustToNSResponse/ErrorMessage"/>
</enrich>
</else>
</filter>
<send/>
</outSequence>
</target>
<publishWSDL key="conf:/resources/wsdls/Customer.wsdl"/>
<parameter name="serviceType">proxy</parameter>
<description/>
</proxy>
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="ChildCustomerToSnipp"
transports="jms"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="customerInternalId"
expression="//InternalID"/>
<log level="full" separator="**Consumed from IN MQ before Seq**"/>
<sequence key="ConvertCustomerSoapToJSONSeq"/>
</inSequence>
<outSequence>
<log level="full" separator="**Consumed from OUT Seq**"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="snippMemberId"
expression="json-eval($.Data)"/>
<log level="custom" separator="**From Out Seq before Update**">
<property xmlns:ns="http://org.apache.synapse/xsd"
name="DataProperty"
expression="get-property('snippMemberId')"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="customerInternalId"
expression="get-property('customerInternalId')"/>
</log>
<sequence key="UpdateSnippMemeber"/>
</outSequence>
</target>
<parameter name="transport.jms.ContentType">text/xml</parameter>
<parameter name="transport.jms.Destination">Teacher.Q</parameter>
<description/>
</proxy>

How to send to multiple endpoints in wso2esb

I am using wso2esb-4.8.1,
I wish to log the transaction details after response back to client.
For that I have written Proxy as well as sequence but wso2esb-4.8.1 is not supporting that with send mediator ,because I want t use load balance for every endpoint where as same logic is working in CallOUt mediator with URL option not with address endpoint .
proxy
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Test_Proxy" transports="https http" startOnLoad="true" trace="disable">
<description/>
<target>
<inSequence onError="FaultSeq">
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true" scope="default" type="STRING"/>
<log>
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" name="ProxyInRequest"
expression="/soapenv:Envelope"/>
</log>
<xquery key="ProxyRequestTransformation">
<variable xmlns:ns="http://org.apache.synapse/xsd" name="Operation" expression="//Operation/text()" type="STRING"/>
<variable xmlns:ns="http://org.apache.synapse/xsd" name="ServiceNameSpace" expression="//ServiceNameSpace/text()" type="STRING"/>
<variable name="Payload" type="DOCUMENT_ELEMENT"/>
<variable xmlns:ns="http://org.apache.synapse/xsd" name="ServiceName" expression="//Service/text()" type="STRING"/>
</xquery>
<send>
<endpoint>
<address uri="http://localhost:8081/middleware/services/test1" format="soap11"/>
</endpoint>
</send>
</inSequence>
<outSequence onError="FaultSeq">
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
<property action="set" name="RESPONSE" scope="default" type="STRING" value="true"/>
<send/>
<sequence key="AuditSeq"/>
</outSequence>
</target>
<publishWSDL key="EaiEnvelope"/>
</proxy>
In above proxy i have used default send mediator after that trying to do audit in same flow ,My client is getting response back but details are not auditing even not getting any error.
My sequence
<sequence xmlns="http://ws.apache.org/ns/synapse" name="AuditSeq"> <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true" scope="default" type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="RESULT_CODE" expression="get-property('ResultCode')" scope="default" type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="RESULT_MESSAGE" expression="get-property('ResultMessage')" scope="default" type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="REFERENCE_ID" expression="get-property('ReferenceID')" scope="default" type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="FAULT_DETAILS" expression="concat(get-property('ERROR_CODE'),get-property('ERROR_MESSAGE'))" scope="default" type="STRING"/>
<payloadFactory media-type="xml">
<format>
<open:processRequest xmlns:open="http://www.openuri.org/">
<aud:Auditor xmlns:aud="http://jhm.kkk.fff/Auditor">
<aud:Request>
<aud:Operation_Name>processRequest</aud:Operation_Name>
<aud:Auditor_InputData>
<aud:Result_Code>$1</aud:Result_Code>
<aud:Result_Message>$2</aud:Result_Message>
<aud:Reference_Id>$3</aud:Reference_Id>
</aud:Auditor_InputData>
</aud:Request>
</aud:Auditor>
</open:processRequest>
</format>
<args>
<arg evaluator="xml" expression="get-property('RESULT_CODE')"/>
<arg evaluator="xml" expression="get-property('RESULT_MESSAGE')"/>
<arg evaluator="xml" expression="get-property('REFERENCE_ID')"/>
</args>
</payloadFactory>
<header name="Action" scope="default" value="http://www.openuri.org/processRequest"/>
<send>
<endpoint>
<address uri="http://localhost:8081/middleware/services/AuditService" format="soap11"/>
</endpoint>
</send>
<log>
<property name="aftersend" value="message going out or not"/>
</log>
</sequence>
With above send mediator is not working .But after send my log is printing.
If i replace send mediator with CallOut URL option its working fine.
<callout serviceURL="http:///localhost:8081/middleware/services/AuditService">
<source type="envelope"/>
<target key="IsThisResponse"/>
</callout>
In above we are not able to use loadbalancing.For that I trying for send mediator.
Is any way to do this.
I thouhgt wso2esb-4.8.1 is become stable but again its having drawbacks.
Thanks in advance.
Please try by changing the send mediator in your proxy as mentioned here it may help you
<send receive="AuditSeq">
<endpoint>
<address uri="http://localhost:8081/middleware/services/test1" format="soap11"/>
</endpoint>
</send>

Iterate Mediator sends duplicate payload almost always

We are trying out a scenario where we want to iterate over a list of nodes and make a POST call to some service with each individual request payload. We are seeing the iterate mediator actually sends two elements in that call and
that causes issues on the API end.
I have a mock service deployed locally that returns response say :
<result>
<row>
<product_id>8351</product_id>
<event_key>17708</event_key>
<event_code>AEONBM</event_code>
<show_title>Some Show</show_title>
<venue_name>Eugene ONeill Theatre</venue_name>
<area>ORCHC</area>
<row>C</row>
<seat_num>103</seat_num>
<seat_increment>1</seat_increment>
<marketing_code>PREMIUM</marketing_code>
<Cost>352.0000</Cost>
</row>
<row>
<product_id>8351</product_id>
<event_key>17708</event_key>
<event_code>AEONBM</event_code>
<show_title>Some Show</show_title>
<venue_name>Eugene ONeill Theatre</venue_name>
<area>ORCHC</area>
<row>C</row>
<seat_num>104</seat_num>
<seat_increment>1</seat_increment>
<marketing_code>PREMIUM</marketing_code>
<Cost>352.0000</Cost>
</row
</result>
Here is how my proxy service looks like:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="CreateListingFromGetLocation"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full">
<property name="text" value="Triggering getLocation API call.."/>
</log>
<send receive="createListingsFromGetLocationResponseSequence">
<endpoint>
<http method="get" uri-template="http://localhost:8989/GetLocation/"/>
</endpoint>
</send>
<property name="OUT_ONLY" value="true"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</target>
<description/>
</proxy>
Here is my receiving sequence that is using the iterate mediator:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="createListingsFromGetLocationResponseSequence">
<iterate xmlns:tem="http://tempuri.org" xmlns:ns="http://org.apache.synapse/xsd" expression="//result/row">
<target>
<sequence>
<log level="full">
<property name="LocationRow" value="Row element from GetLocationResponse"></property>
</log>
<payloadFactory media-type="xml">
<format>
<listing xmlns="">
<eventId>$1</eventId>
<eventDescription>$2</eventDescription>
<pricePerTicket>
<amount>$3</amount>
<currency>USD</currency>
</pricePerTicket>
<quantity>$4</quantity>
<section>$5</section>
<rows>$6</rows>
<seats>$7</seats>
<splitOption>NONE</splitOption>
</listing>
</format>
<args>
<arg expression="//event_key" evaluator="xml"></arg>
<arg expression="//show_title" evaluator="xml"></arg>
<arg expression="//Cost" evaluator="xml"></arg>
<arg expression="//seat_increment" evaluator="xml"></arg>
<arg expression="//area" evaluator="xml"></arg>
<arg expression="//row/row" evaluator="xml"></arg>
<arg expression="//seat_num" evaluator="xml"></arg>
</args>
</payloadFactory>
<log level="full">
<property name="ListingRequest" value="Listing request xml"></property>
</log>
<property name="Content-Type" value="application/xml" scope="transport" type="STRING"></property>
<property name="messageType" value="application/xml" scope="transport" type="STRING"></property>
<property name="TARGET_HOST" value="srwd30" scope="transport" type="STRING"></property>
<property name="HTTP_METHOD" value="POST" scope="transport" type="STRING"></property>
<send>
<endpoint>
<http format="pox" method="post" uri-template="http://www.srwd30.com/listings/v1/"></http>
</endpoint>
</send>
</sequence>
</target>
</iterate>
</sequence>
Firstly, I see that it is iterating over each xml node properly, here are some logs indicating that:
[2014-04-22 13:29:42,020] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:3bc14a33-3a7a-478e-bdbf-720f1ec855a5, Direction: response, LocationRow = Row element from GetLocationResponse, Envelope: <?xml version="1.0" encoding="utf-8
"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><row>
<product_id>8351</product_id>
<event_key>17708</event_key>
<event_code>AEONBM</event_code>
<show_title>Some Show</show_title>
<venue_name>Eugene ONeill Theatre</venue_name>
<area>ORCHC</area>
<row>D</row>
<seat_num>103</seat_num>
<seat_increment>1</seat_increment>
<marketing_code>PREMIUM</marketing_code>
<Cost>352.0000</Cost>
</row></soapenv:Body></soapenv:Envelope>
[2014-04-22 13:29:42,021] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:0e04ac15-a0bf-41a3-a7d7-80a1401d3efc, Direction: response, ListingRequest = Listing request xml, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:En
velope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><listing><eventId>17708</eventId><eventDescription>Some Show</eventDescription><pricePerTicket><amount>352.0000</amount><currency>USD</currency></pricePerTicket><quantity>1</quantity><section>ORCHC</section><rows
>C</rows><seats>103</seats><splitOption>NONE</splitOption></listing></soapenv:Body></soapenv:Envelope>
But on my API I see that we are receiving duplicate or two root nodes:
Content-Type: application/xml
Headers: {cache-control=[no-cache], connection=[Keep-Alive],
content-type=[application/xml], host=[www.srwd30.com], http_method=[POST], messagetype=[application/xml], target_host=[srwd30], transfer-encoding=
[chunked], user-agent=[Synapse-PT-HttpComponents-NIO]}
Payload: <listing><eventId>17708</eventId><eventDescription>Some Show</eventDescription><pricePerTicket><amount>352.0000</amount><currency>USD</currenc
y></pricePerTicket><quantity>1</quantity><section>ORCHC</section><rows>C</rows><seats>103</seats><splitOption>NONE</splitOption></listing><listing><eventId>1770
8</eventId><eventDescription>Some Show</eventDescription><pricePerTicket><amount>352.0000</amount><currency>USD</currency></pricePerTicket><quantity>1<
/quantity><section>ORCHC</section><rows>D</rows><seats>104</seats><splitOption>NONE</splitOption></listing>
--------------------------------------
2014-04-22 19:01:51,468 [e14f#fbf/http://www.srwd30.com/listings/v1/] priority=WARN app_name=shared-stubhubjobs thread=http-0.0.0.0-
8080-8 location=AbstractJAXBProvider line=112 javax.xml.bind.UnmarshalException
- with linked exception:
[com.ctc.wstx.exc.WstxParsingException: Illegal to have multiple roots (start tag in epilog?).
at [row,col {unknown-source}]: [1,291]]
From the looks of it, iterator is sending two elements when I make that send call. Am i missing something or doing something wrong? How can make each call independent from other?
I got the issue resolved by adding a Action header using urn:test value for that header. I realized that this was causing that duplicate requests to be sent and sometimes only one request being sent even if the iterator has about 10 records.
<proxy name="PushInventory"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<log level="full">
<property name="STATUS"
value="+++++++++++++++++ Inside PushInventory Proxy Service ++++++++++++++++++"/>
</log>
<iterate xmlns:tem="http://tempuri.org"
xmlns:ns="http://org.apache.synapse/xsd"
id="pushInventoryIterator"
expression="//result/row"
sequential="true">
<target>
<sequence>
<payloadFactory media-type="xml">
<format>
<listing xmlns="">
<eventId>$1</eventId>
<eventDescription>$2</eventDescription>
<pricePerTicket>
<amount>$3</amount>
<currency>USD</currency>
</pricePerTicket>
<quantity>$4</quantity>
<section>$5</section>
<rows>$6</rows>
<seats>$7</seats>
<splitOption>NONE</splitOption>
</listing>
</format>
<args>
<arg evaluator="xml" expression="//event_key"/>
<arg evaluator="xml" expression="//show_title"/>
<arg evaluator="xml" expression="//Cost"/>
<arg evaluator="xml" expression="//seat_increment"/>
<arg evaluator="xml" expression="//area"/>
<arg evaluator="xml" expression="//row_desc"/>
<arg evaluator="xml" expression="//seat_num"/>
</args>
</payloadFactory>
<log level="full">
<property name="STATUS"
value="++++++++++++ Invoking Listing EndPoint ++++++++++++++"/>
</log>
<property name="Authorization"
value="Basic dafdsfadsfdsafdsfdsafdsafsdfadsf"
scope="transport"
type="STRING"/>
<property name="Content-Type"
value="application/xml"
scope="transport"
type="STRING"/>
<property name="messageType"
value="application/xml"
scope="axis2"
type="STRING"/>
<property name="HTTP_METHOD" value="POST" scope="transport" type="STRING"/>
<header name="Action" scope="default" value="urn:test"/>
<send>
<endpoint key="ListingEndPoint"/>
</send>
</sequence>
</target>
</iterate>
</inSequence>
<outSequence>
<log level="full">
<property name="STATUS"
value="+++++++++++++++++ Inside OutSequence of PushInventory ++++++++++++++++++"/>
</log>
<aggregate>
<completeCondition>
<messageCount min="10" max="10"/>
</completeCondition>
<onComplete xmlns:ns2="com.blah.blah" expression="//listing">
<log level="full" separator=",">
<property name="STATUS"
value="+++++++++++++++++ Aggregating responses back ++++++++++++++++++"/>
</log>
<enrich>
<source type="envelope" clone="true"/>
<target type="body"/>
</enrich>
<send/>
</onComplete>
</aggregate>
</outSequence>
</target>
</proxy>
You put your log before the iterator mediator and see what you're receiving from the endpoint. It may contain duplicate entries. Then within iterate you have another log mediator. Check for records are right.

How to Know the URL of Client In wso2 esb for Filter

i am doing filter based on the URL so i wish to know the FROM which service i am getting request .Means i wish to know the URL of Client
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Emp" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="username" expression="//username/text()" scope="default" type="STRING"/>
<property name="password" expression="//password/text()" scope="default" type="STRING"/>
<payloadFactory>
<format>
<send xmlns="">
<username>$1</username>
<password>$2</password>
</send>
</format>
<args>
<arg expression="get-property('username')"/>
<arg expression="get-property('password')"/>
</args>
</payloadFactory>
<send receive="Emp_Seq">
<endpoint>
<address uri="http://192.168.1.65:8282/services/Login"/>
</endpoint>
</send>
</inSequence>
<outSequence/>
</target>
<description></description>
</proxy>
URL of above Proxy is http://192.168.1.65:8282/services/Emp
my second proxy is which will do some logic based on first proxy
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Login" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="client_ip_address" expression="get-property('axis2','REMOTE_ADDR')" scope="default" type="STRING"/>
<property name="username" expression="//username/text()" scope="default" type="STRING"/>
<property name="password" expression="//password/text()" scope="default" type="STRING"/>
<property name="From" expression="get-property('From')"/>
<property name="Address" expression="get-property('To')"/>
<filter xmlns:ns="http://org.apache.synapse/xsd" xpath="get-property('From')='/services/Emp'">
<then>
<payloadFactory>
<format>
<ResponseJSON xmlns="">
<Status>404</Status>
<Exception>Not Found</Exception>
<Total>0</Total>
</ResponseJSON>
</format>
</payloadFactory>
<send/>
</then>
<else>
<payloadFactory>
<format>
<p:login xmlns:p="http://authentication.services.core.carbon.wso2.org">
<p:username>$1</p:username>
<p:password>$2</p:password>
<p:remoteAddress>$3</p:remoteAddress>
</p:login>
</format>
<args>
<arg expression="//username/text()"/>
<arg expression="//password/text()"/>
<arg expression="get-property('client_ip_address')"/>
</args>
</payloadFactory>
<header name="Action" value="urn:login"/>
<log level="full"/>
<send receive="Login_Seq">
<endpoint>
<address uri="https://192.168.1.65:9443/services/AuthenticationAdmin" format="soap11"/>
</endpoint>
</send>
</filter>
</inSequence>
<outSequence>
<log level="full"/>
</outSequence>
</target>
<description></description>
</proxy>
The issue is get-property('To') is giving Address=/services/Login where as get-property('From') is giving senderAddress=null
How can i manage this i trie d with lot of propertys even though its not working
like
<property name="senderAddress" expression="get-property('transport', 'From')"/>
<property name="Sender Address" expression="$url:From"/>
<header name="From" expression="get-property( 'From')"/>
<property name="PRESERVE_WS_ADDRESSING" value="true"/>
<property xmlns:wsa="http://www.w3.org/2005/08/addressing" name="$header" expression="$header/wsa:From"/>
This propertys also not working we don't have any option in wso2 esb If you know this please edit my proxy roughly ..its simple depanding logic but it is not working in WSO2
thanks in advance
You should be able to get the client's address with the REMOTE_HOST or REMOTE_ADDR properties. Please refer http://wso2.org/project/esb/java/4.0.3/docs/properties_guide.html#http

How Can I handle Error sequence in WSO2ESB

i want handle error using fault sequence but i wish to customize it with delete operation
my scenario is while i am inserting in 2 tables if error occurred in 2nd table insertion i need to delete 1 st row insertion also my config is below
<proxy xmlns="http://ws.apache.org/ns/synapse" name="ErrorHandling" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target >
<inSequence onError="fault">
<property name="eno" expression="//eno/text()" scope="default" type="STRING"/>
<property name="ename" expression="//ename/text()" scope="default" type="STRING"/>
<property name="esal" expression="//esal/text()" scope="default" type="STRING"/>
<property name="deptname" expression="//deptname/text()" scope="default" type="STRING"/>
<property name="deptid" expression="//deptid/text()" scope="default" type="STRING"/>
<payloadFactory>
<format>
<p:insert_emp_operation xmlns:p="http://ws.wso2.org/dataservice">
<xs:eno xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:eno>
<xs:ename xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:ename>
<xs:esal xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:esal>
</p:insert_emp_operation>
</format>
<args>
<arg expression="get-property('eno')"/>
<arg expression="get-property('ename')"/>
<arg expression="get-property('esal')"/>
</args>
</payloadFactory>
<send receive="Error_Seq">
<endpoint>
<address uri="http://localhost:9764/services/emp_DataService/" format="soap11"/>
</endpoint>
</send>
<log level="full"/>
</inSequence>
<outSequence onError="fault">
<send/>
<log level="full"/>
</outSequence>
</target>
<description></description>
</proxy>
and sequence is like this
<sequence xmlns="http://ws.apache.org/ns/synapse" name="Error_Seq" onError="fault">
<property xmlns:f="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd" name="ID" expression="//f:ID/text()" scope="default" type="STRING"/>
<log>
<property xmlns:ns="http://org.apache.synapse/xsd" name="faisal" expression="get-property('ID')"/>
</log>
<payloadFactory>
<format>
<p:insert_dept_operation xmlns:p="http://ws.wso2.org/dataservice">
<xs:deptno xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:deptno>
<xs:deptname xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:deptname>
<xs:deptid xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:deptid>
</p:insert_dept_operation>
</format>
<args>
<arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('ID')"/>
<arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('deptname')"/>
<arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('deptid')"/>
</args>
</payloadFactory>
<send>
<endpoint>
<address uri="http://localhost:9764/services/dept_DataService/" format="soap11"/>
</endpoint>
</send>
</sequence>
fault sequenceis like this
<sequence xmlns="http://ws.apache.org/ns/synapse" name="fault">
<property xmlns:ns="http://org.apache.synapse/xsd" name="ID" expression="get-property('ID')" scope="default" type="STRING"/>
<log level="full">
<property name="MESSAGE" value="Executing default 'fault' sequence"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="Property" expression="get-property('ID')"/>
</log>
<payloadFactory>
<format>
<p:Delete_Op xmlns:p="http://ws.wso2.org/dataservice">
<xs:eno xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:eno>
</p:Delete_Op>
</format>
</payloadFactory>
<send>
<endpoint>
<address uri="http://localhost:9764/services/dept_DataService/" format="soap11"/>
</endpoint>
</send>
</sequence>
but its not working its working while the DSS Is in OFF mode let me know when DSS is In Running mode how to delete the 1st table row
In your scenario when update fails at DSS, it will send back a SOAP fault to the ESB.
Since ESB this is still just another message response, and it will not goto the fault sequence, unless you explicitly check the message and do the necessary actions.
So you have to declare comming message is a SOAP_FAULT so you hace to say it is a SOAP_FAULT and force it to error sequance. This is explained in [1].
[1] http://maharachchi.blogspot.com/2012/09/now-you-can-send-soapfaults-to-fault.html