We have this WSO2 ESB proxy service that's accessible thru its https endpoint. I want to configure this service so that it will also be accessible via http.
I checked the service configuration in the carbon management console and confirmed that both https and http endpoint were already enabled:
https://10.20.0.20:8245/services/<service_name>
http://10.20.0.20:8282/services/<service_name>
Also, the axis2.xml file in ESB_HOME}/repository/conf/axis2/ seems to be configured just fine.
<!-- ================================================= -->
<!-- Transport Ins (Listeners) -->
<!-- ================================================= -->
<!-- the non blocking http transport based on HttpCore + NIO extensions -->
<transportReceiver name="http" class="org.apache.synapse.transport.nhttp.HttpCoreNIOListener">
<parameter name="port" locked="false">8280</parameter>
<parameter name="non-blocking" locked="false">true</parameter>
<!--parameter name="bind-address" locked="false">hostname or IP address</parameter-->
<!--parameter name="WSDLEPRPrefix" locked="false">https://apachehost:port/somepath</parameter-->
<parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.NHttpGetProcessor</parameter>
<!--<parameter name="priorityConfigFile" locked="false">location of priority configuration file</parameter>-->
<parameter name="disableRestServiceDispatching" locked="false">true</parameter>
</transportReceiver>
<!-- the non blocking https transport based on HttpCore + SSL-NIO extensions -->
<transportReceiver name="https" class="org.apache.synapse.transport.nhttp.HttpCoreNIOSSLListener">
<parameter name="port" locked="false">8243</parameter>
<parameter name="non-blocking" locked="false">true</parameter>
<!--parameter name="bind-address" locked="false">hostname or IP address</parameter-->
<!--parameter name="WSDLEPRPrefix" locked="false">https://apachehost:port/somepath</parameter-->
<!--<parameter name="priorityConfigFile" locked="false">location of priority configuration file</parameter>-->
<parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.NHttpGetProcessor</parameter>
<parameter name="disableRestServiceDispatching" locked="false">true</parameter>
<parameter name="keystore" locked="false">
<KeyStore>
<Location>repository/resources/security/iaascol.jks</Location>
<Type>JKS</Type>
<Password>***</Password>
<KeyPassword>rotcelloc</KeyPassword>
</KeyStore>
</parameter>
<parameter name="truststore" locked="false">
<TrustStore>
<Location>repository/resources/security/client-truststore.jks</Location>
<Type>JKS</Type>
<Password>***</Password>
</TrustStore>
</parameter>
<!--<parameter name="SSLVerifyClient">require</parameter>
supports optional|require or defaults to none -->
</transportReceiver>
Port offset in ESB_HOME}/repository/conf/carbon.xml is set to 2.
<Offset>2</Offset>
I can't seem to access this proxy service thru its http endpoint URL. The version of WSO2 ESB is 4.5.0. Please let me know which configuration do I have to check / set. Thanks in advance.
Edit: Below is the proxy service config as well as netstat result.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="disbursement" statistics="disable"
trace="enable" transports="https,http">
<target>
<inSequence>
<property action="set" name="EXECUTION_CONTEXT"
scope="default" type="STRING" value="disbursement"/>
<property action="set"
expression="fn:concat(//*[local-name()='Header']/*[local-name()='TrackingID'], '.xml')"
name="DumpFileName" scope="default" type="STRING"/>
<log category="INFO" level="full" separator=",">
<property name="EVENT_TYPE" value="PROCESSING_STARTED"/>
<property expression="get-property('DumpFileName')" name="FILENAME"/>
</log>
<property action="set" name="DumpFilePath" scope="default"
type="STRING" value="/home/user1/data/disbursement/incoming"/>
<class name="se.seman.wso2.mediator.WriteFile"/>
<property action="set" name="TopicName" scope="default"
type="STRING" value="VirtualTopic.seman.iaas.user1.topic.disbursement.out"/>
<property action="set" name="ResultCode" scope="default"
type="STRING" value="0"/>
<!--
TODO correct problem with xpath
validate source="/default/xpath">
<on-fail>
<property action="set" name="ResultCode"
scope="default" type="STRING" value="100"/>
<property action="set"
expression="get-property('ERROR_MESSAGE')"
name="ResultMessage" scope="default"
type="STRING"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Namespaces.user1.se:Cmf:InfoModel:FinancialManagement:Payment:Disbursment:0002"/>
<log category="INFO" level="full" separator=",">
<property name="MESSAGE" value="Schema validation failed"/>
<property
expression="get-property('ERROR_CODE')"
name="ERROR_CODE"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Namespaces.user1.se:Cmf:InfoModel:FinancialManagement:Payment:Disbursment:0002"/>
<property
expression="get-property('ERROR_MESSAGE')"
name="ERROR_MESSAGE"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Namespaces.user1.se:Cmf:InfoModel:FinancialManagement:Payment:Disbursment:0002"/>
</log>
<property action="set" name="RESPONSE"
scope="default" type="STRING" value="true"/>
</on-fail>
<schema key="conf:user1/ESBConfig/Common/NetPosti/resources/Disbursement_0002.xsd"/>
</validate -->
<log category="INFO" level="headers" separator=",">
<property name="MESSAGE" value="Before Topic"/>
<property expression="get-property('ERROR')" name="ERROR"/>
</log>
<filter xpath="get-property('ResultCode') = '0'">
<then>
<property action="set" name="ResultMessage"
scope="default" type="STRING" value="OK"/>
<class name="se.seman.wso2.mediator.WriteActiveMQTopic"/>
</then>
<else/>
</filter>
<header action="remove" name="To"/>
<property action="remove" name="NO_ENTITY_BODY" scope="axis2"/>
<property action="set" name="RESPONSE" scope="default"
type="STRING" value="true"/>
<payloadFactory>
<format>
<disr:DisbursementResponse xmlns:disr="urn:Namespaces.user1.se:Service:FinancialManagement:Payment:Disbursement:Response:0001">
<disr:ResponseCode>$1</disr:ResponseCode>
<disr:Message>$2</disr:Message>
</disr:DisbursementResponse>
</format>
<args>
<arg expression="get-property('ResultCode')"/>
<arg expression="get-property('ResultMessage')"/>
</args>
</payloadFactory>
<log category="INFO" level="full" separator=","/>
<send/>
</inSequence>
<outSequence>
<log category="INFO" level="full" separator=",">
<property name="MESSAGE" value="On the way back.."/>
</log>
<send/>
</outSequence>
<faultSequence>
<log category="INFO" level="full" separator=",">
<property name="MESSAGE" value="Error in Call!"/>
</log>
<property action="set" name="RESPONSE" scope="default"
type="STRING" value="true"/>
<enrich>
<source clone="true" type="inline">
<disr:DisbursementResponse xmlns:disr="urn:Namespaces.user1.se:Service:FinancialManagement:Payment:Disbursement:0001">
<disr:ResponseCode>900</disr:ResponseCode>
<disr:Message>General error</disr:Message>
</disr:DisbursementResponse>
</source>
<target action="replace" type="body"/>
</enrich>
</faultSequence>
</target>
<publishWSDL key="conf:user1/ESBConfig/Common/NetPosti/resources/DisbursementService0002.wsdl">
<resource
key="conf:user1/ESBConfig/Common/NetPosti/resources/Disbursement_0002.xsd" location="Disbursement_0002.xsd"/>
</publishWSDL>
[user1#ip-10-20-0-20 ~]$ netstat -pnlt
Proto Recv-Q Send-Q Local Address Foreign Address
State PID/Program name
tcp 0 0 :::8245 :::*
LISTEN 2454/java
tcp 0 0 :::8282 :::*
LISTEN 2454/java
turned out this was only a firewall issue. port 8282 was blocked in wso2 firewall (iptables). thanks for all answers!
Related
I am using WSO2 ESB 6.4.0 and APIM 2.6.0
I am working on adding certificate in APIM server using rest API of APIM application.
In the request of adding a new certificate, the post request should be form-data.
So, to automate the process, I am using ESB server. I have written a proxy which will pick the certificate file and process it. Below is my proxy code
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="ClientSslCertificateAdd-APIM" startOnLoad="true" transports="http https vfs" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<!-- <enrich>
<source clone="true" type="body"/>
<target property="originalBody" type="property" />
</enrich>
<property expression="get-property('originalBody')"
name="payloadposttexttransformation"
scope="default"
type="STRING"/> -->
<property expression="$body/*" name="payload" scope="default" type="STRING"/>
<property expression="get-property('payload')" name="xml form certificate captured ===" scope="default" type="STRING"/>
<xslt description="" key="xmltotext"/>
<property expression="$body/*" name="payloadpostmapping" scope="default" type="STRING"/>
<property name="filename" scope="default" type="STRING" value="filename_certifiate"/>
<property name="alias" scope="default" type="STRING" value="alias_certifiate"/>
<property name="endpoint" scope="default" type="STRING" value="endpoint_certifiate"/>
<property name="uri.var.host" scope="default" type="STRING" value="http://apimserver.com/"/>
<property name="uri.var.context" scope="default" type="STRING" value="certificates"/>
<property expression="get-property('alias')" name="uri.var.resourcepath" scope="default" type="STRING"/>
<property name="Authorization" scope="transport" type="STRING" value="Bearer token"/>
<call>
<endpoint>
<http method="get" uri-template="{uri.var.host}/{uri.var.context}/{uri.var.resourcepath}"/>
</endpoint>
</call>
<property expression="json-eval($.status)" name="currentstatusoftobeaddedalias" scope="default" type="STRING"/>
<filter regex="Expired" source="get-property('currentstatusoftobeaddedalias')">
<then>
<property expression="get-property('alias')" name="alias" scope="default" type="STRING"/>
<property expression="get-property('endpoint')" name="endpoint" scope="default" type="STRING"/>
<property name="Authorization" scope="transport" type="STRING" value="Bearer token"/>
<property name="messageType" scope="axis2" type="STRING" value="multipart/form-data"/>
<payloadFactory media-type="xml">
<format>
<root xmlns="">
<certificate charset="UTF-8" contentType="text/plain" xmlns="http://org.apache.axis2/xsd/form-data">$3</certificate>
<alias xmlns="http://org.apache.axis2/xsd/form-data">$1</alias>
<endpoint xmlns="http://org.apache.axis2/xsd/form-data">$2</endpoint>
</root>
</format>
<args>
<arg evaluator="xml" expression="$ctx:alias"/>
<arg evaluator="xml" expression="$ctx:endpoint"/>
<arg evaluator="xml" expression="$ctx:payloadpostmapping"/>
</args>
</payloadFactory>
<property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
<!-- <property name="ContentType" scope="axis2" value="multipart/form-data" type="STRING"/> -->
<property name="messageType" scope="axis2" type="STRING" value="multipart/form-data"/>
<!-- <call>
<endpoint>
<http format="rest" method="post" uri-template="http://apimserver.com"/>
</endpoint>
</call> -->
<send>
<endpoint>
<http method="POST" format="rest"
uri-template="http://apimserver.com"/>
</endpoint>
</send>
</then>
<else>
<log>
<property name="alreadypresent" value="with entered alias name, certificate is active"/>
</log>
</else>
</filter>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
<parameter name="transport.PollInterval">5</parameter>
<parameter name="transport.vfs.FileURI">file:///opt/new/esb/clientSSLcertificate_repo/</parameter>
<parameter name="transport.vfs.ContentType">application/xml;charset=UTF-8</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///opt/new/esb/clientSSLcertificate_repo/failed_clientSSLcertificate</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///opt/new/esb/clientSSLcertificate_repo/updated_clientSSLcertificate</parameter>
</proxy>
I am first checking what is the status of the alias present in APIM server, if its expired then it should add the certificate.
also, I am picking the file from ESB local directory in xml form and converting the same in text/plain format in order to remove any residues and ensure that I am sending proper message to APIM server.
Once the request is hit to APIM server, I am getting below error in ESB server
DEBUG - wire HTTP-Sender I/O dispatcher-2 >> "{"code":500,"message":"Internal server error","description":"The server encountered an internal error. Please contact administrator.","moreInfo":"","error":[]}[\r][\n]"
DEBUG - wire HTTP-Sender I/O dispatcher-2 >> "0[\r][\n]"
DEBUG - wire HTTP-Sender I/O dispatcher-2 >> "[\r][\n]"
DEBUG - headers http-outgoing-6 << HTTP/1.1 500 Internal Server Error
DEBUG - headers http-outgoing-6 << Server: nginx/1.16.1
DEBUG - headers http-outgoing-6 << Date: Wed, 06 Nov 2019 22:06:41 GMT
DEBUG - headers http-outgoing-6 << Content-Type: application/json
DEBUG - headers http-outgoing-6 << Transfer-Encoding: chunked
DEBUG - headers http-outgoing-6 << Connection: keep-alive
and error from APIM server is
ERROR - GlobalThrowableMapper An Unknown exception has been captured by global exception mapper.
org.apache.cxf.interceptor.Fault: Couldn't find MIME boundary: --MIMEBoundary_4a754414be212aae0a86dd7fe9ddbf07662811acf9d618ec
at org.apache.cxf.interceptor.AttachmentInInterceptor.handleMessage(AttachmentInInterceptor.java:60)
at org.apache.cxf.jaxrs.ext.MessageContextImpl.createAttachments(MessageContextImpl.java:284)
at org.apache.cxf.jaxrs.ext.MessageContextImpl.get(MessageContextImpl.java:79)
at org.apache.cxf.jaxrs.impl.tl.ThreadLocalMessageContext.get(ThreadLocalMessageContext.java:42)
at org.apache.cxf.jaxrs.utils.multipart.AttachmentUtils.getMultipartBody(AttachmentUtils.java:143)
at org.apache.cxf.jaxrs.utils.multipart.AttachmentUtils.getAttachments(AttachmentUtils.java:155)
at org.apache.cxf.jaxrs.provider.MultipartProvider.readFrom(MultipartProvider.java:149)
at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1355)
at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1307)
at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:836)
at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:795)
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:214)
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:191)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:220)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.wso2.carbon.identity.context.rewrite.valve.TenantContextRewriteValve.invoke(TenantContextRewriteValve.java:80)
at org.wso2.carbon.identity.authz.valve.AuthorizationValve.invoke(AuthorizationValve.java:91)
at org.wso2.carbon.identity.auth.valve.AuthenticationValve.invoke(AuthenticationValve.java:65)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:99)
at org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
at org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:57)
at org.wso2.carbon.event.receiver.core.internal.tenantmgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:48)
at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:62)
at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:159)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1775)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1734)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Couldn't find MIME boundary: --MIMEBoundary_4a754414be212aae0a86dd7fe9ddbf07662811acf9d618ec
at org.apache.cxf.attachment.AttachmentDeserializer.initializeRootMessage(AttachmentDeserializer.java:140)
at org.apache.cxf.attachment.AttachmentDeserializer.initializeAttachments(AttachmentDeserializer.java:109)
at org.apache.cxf.interceptor.AttachmentInInterceptor.handleMessage(AttachmentInInterceptor.java:58)
... 54 more
From the error log it seems that APIM server is unable to get the attach files from ESB and which is why it is unable to process the request.
Does APIM 2.6.0 support multipart/form-data
Thanks
We had similar issue and we had to update messageFormatters and messageBuilders in axis2/axis2.xml file (in both ESB and APIM):
update messageFormatters:
<!-- <messageFormatter contentType="multipart/form-data"
class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/ -->
<messageFormatter contentType="multipart/form-data"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
update messageBuilders
<!-- messageBuilder contentType="multipart/form-data"
class="org.apache.axis2.builder.MultipartFormDataBuilder"/ -->
<messageBuilder contentType="multipart/form-data"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
These updates should change the transport to stream the payload without parsing and rebuilding it
url likes:
http://ict.esg.ilfseducation.com`/gtrapi/api/profilesystem?`d1=17-10-2018&d2=17-10-2018
Iam trying this code to pass with dates dynamically d1 and d2 but not working.but how to pass dates with dynamically please any one suggest me.i have try this another url with sigle parms working fine.but dates was not working any one please suggeat me.
api:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/gtrapi/api/profilesystem?" name="SCR_profileapi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" protocol="http" uri-template="/{date1}/{date2}">
<inSequence>
<property description="http" name="HTTP_SC" scope="axis2" type="STRING" value="404"/>
<log level="full"/>
<send>
<endpoint key="SCR_profileendpoint"/>
</send>
</inSequence>
<outSequence>
<switch source="get-property('axis2','HTTP_SC')">
<case regex="200">
<log description="200log" level="custom">
<property expression="$ctx:ERROR_CODE" name="200reserrorcode"/>
</log>
<send/>
</case>
<default>
<log description="reslog" level="custom">
<property expression="$ctx:ERROR_CODE" name="reserrorcode"/>
<property expression="$ctx:ERROR_MESSAGE" name="reserrormessage"/>
<property expression="get-property('axis2','HTTP_SC')" name="reshttpsc"/>
</log>
</default>
</switch>
<send/>
</outSequence>
<faultSequence>
<switch source="get-property('axis2','HTTP_SC')">
<case regex="200">
<log description="200log" level="custom">
<property expression="$ctx:ERROR_CODE" name="200reserrorcode"/>
</log>
</case>
<default>
<log description="reslog" level="custom">
<property expression="$ctx:ERROR_CODE" name="reserrorcode"/>
<property expression="$ctx:ERROR_MESSAGE" name="reserrormessage"/>
<property expression="get-property('axis2','HTTP_SC')" name="reshttpsc"/>
</log>
</default>
</switch>
<send/>
</faultSequence>
</resource>
</api>
endpoint:
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="SCR_profileendpoint" xmlns="http://ws.apache.org/ns/synapse">
<http uri-template="http://ict.esg.ilfseducation.com/gtrapi/api/profilesystem?d1={uri.var.service.date1}&d2={uri.var.service.d2}" method="get">
</http>"/>
</endpoint>
I am getting below error while calling http endpoint:-
The endpoint is HTTP endpoint which I am using.
Also added timeout parameters in axis2.xml and axis2.blocking.xml.
But it did not work.
Can anyone provide any solution to it?
HTTPSender Unable to sendViaPost to url[http://*********]
org.apache.commons.httpclient.NoHttpResponseException: The server ****** failed to respond
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1976)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
the esb proxy looks like below:--
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="mqListener"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<log description="print message" level="full">
<property name="message" value=""In listenAbc1Mq""/>
</log>
<payloadFactory media-type="json">
<format>
{
"orderId": ""
}
</format>
<args>
<arg evaluator="xml" expression="//verkkopvc/text()"/>
</payloadFactory>
<log description="print message" level="full">
<property name="message" value=""after payload factory""/>
</log>
<property name="OUT_ONLY" value="true"/>
<property name="DISABLE_CHUNKING"
scope="axis2"
type="STRING"
value="true"/>
<call blocking="true">
<endpoint key="abc"/>
</call>
<log description="print message" level="full">
<property name="message" value=""Out sequence""/>
</log>
</inSequence>
<outSequence/>
<description/>
</proxy>
I believe the error is printed by your http client. To fix it, do these.
1) Remove <property name="OUT_ONLY" value="true"/>
2) Add <respond/> mediator at the end of inSequence.
am using Active MQ 5.10 version,I have configured it with wso2esb for message processing.
After around 7-10 days Active MQ is throwing tcp connections failure exception,since ESB is not receiving a successful tcp connection it is failing to submit messages in the Queue.
In this case am restarting the server and again it will run for 7-10 days and the same thing repeats.
my questions is
what may be the exact reason for active MQ stops giving successful tcp connection..?
why after restarting the server it returns to normal state..?
is there any best solution to over come this issue..
memory configuration in activemq.xml file
<systemUsage>
<systemUsage sendFailIfNoSpace="true">
<memoryUsage>
<memoryUsage limit="1430 mb"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="300 gb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="100 gb"/>
</tempUsage>
</systemUsage>
</systemUsage>
Here is the Proxy service which is placing message in queue. In the proxy service it will check the user authentication if its true the user can place the message in the queue, here i use a class mediator where in that it connects with the active MQ and places message
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JmsStore2.0"
transports="https http"
startOnLoad="true"
trace="disable"
statistics="enable">
<description/>
<target>
<inSequence onError="fault">
<property name="messageType" value="application/json" scope="axis2"/>
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
<property name="jmsuri" value="tcp://0.0.0.0:61616"/>
<property name="jmsqueue" expression="get-property('transport', 'jmsqueue')"/>
<property name="readingspayload" expression="$body" type="OM"/>
<property name="username" expression="get-property('transport', 'username')"/>
<property name="password" expression="get-property('transport', 'password')"/>
<property name="PartyBranchID"
expression="//FieldValue/text()"
scope="default"
type="STRING"/>
<property name="Body" expression="$body" scope="default" type="STRING"/>
<property name="usercode"
expression="fn:substring-before(get-property('username'),'|')"
scope="default"
type="STRING"/>
<property name="clientid"
expression="fn:substring-after(get-property('username'),'|')"
scope="default"
type="STRING"/>
<property name="requestMsgId"
expression="get-property('MessageID')"
scope="default"
type="STRING"/>
<property name="client_ip_address"
expression="get-property('axis2','REMOTE_ADDR')"
scope="default"
type="STRING"/>
<payloadFactory media-type="xml">
<format>
<send xmlns="">
<username>$1</username>
<password>$2</password>
</send>
</format>
<args>
<arg evaluator="xml" expression="get-property('username')"/>
<arg evaluator="xml" expression="get-property('password')"/>
</args>
</payloadFactory>
<send receive="JmsStore_Seq">
<endpoint>
<address uri="http://localhost:8282/services/Login2.0" format="soap11">
<suspendOnFailure>
<errorCodes>101500,101501,101506,101507,101508,101503,50000</errorCodes>
<initialDuration>30</initialDuration>
<progressionFactor>1.0</progressionFactor>
<maximumDuration>300</maximumDuration>
</suspendOnFailure>
</address>
</endpoint>
</send>
</inSequence>
<outSequence onError="fault">
<send/>
</outSequence>
</target>
</proxy>
Sequence:
<sequence xmlns="http://ws.apache.org/ns/synapse"
name="JmsStore_Seq"
trace="disable">
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="Authentication"
expression="//Authentication/text()"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="UserId"
expression="//UserId/text()"
scope="default"
type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="WorkOUid"
expression="//WorkOUid/text()"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="WorkPartyBranchId"
expression="//WorkPartyBranchId/text()"/>
<filter xmlns:ns="http://org.apache.synapse/xsd"
xpath="get-property('Authentication')=''">
<then>
<payloadFactory media-type="xml">
<format>
<ResponseJSON xmlns="">
<Exception>Service trying to connect inactive service</Exception>
<Status>101503</Status>
</ResponseJSON>
</format>
<args/>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2"/>
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
<property name="RESPONSE" value="true" scope="default" type="STRING"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
<send/>
</then>
<else>
<filter xpath="get-property('Authentication')='false'">
<then>
<payloadFactory media-type="xml">
<format>
<ResponseJSON xmlns="">
<Exception>Authentication Failed</Exception>
<Status>401</Status>
</ResponseJSON>
</format>
<args/>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2"/>
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
<property name="RESPONSE" value="true" scope="default" type="STRING"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
<send/>
</then>
<else>
<property name="jmspayload"
expression="get-property('readingspayload')"
type="OM"/>
<property name="ResponseJSON" expression="$body/ResponseJSON" type="OM"/>
<property name="jmsuri" expression="get-property('jmsuri')"/>
<property name="jmsqueue" expression="get-property('jmsqueue')"/>
<payloadFactory media-type="xml">
<format>
<PLData>
<JMpayload>$1</JMpayload>
<AuthData>$2</AuthData>
<LogData>
<usercode>$3</usercode>
<clientid>$4</clientid>
<requestMsgId>$5</requestMsgId>
</LogData>
</PLData>
</format>
<args>
<arg evaluator="xml" expression="get-property('jmspayload')"/>
<arg evaluator="xml" expression="get-property('ResponseJSON')"/>
<arg evaluator="xml" expression="get-property('usercode')"/>
<arg evaluator="xml" expression="get-property('clientid')"/>
<arg evaluator="xml" expression="get-property('requestMsgId')"/>
</args>
</payloadFactory>
<class name="in.youtility.esb.custommediators.JMSStoreMediator"/>
<payloadFactory media-type="xml">
<format>
<ResponseJSON xmlns="">
<Body>
<Datalist>
<Data>Successfully stored</Data>
</Datalist>
</Body>
<Status>200</Status>
</ResponseJSON>
</format>
<args/>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2"/>
<header name="To" action="remove"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
<property name="RESPONSE" value="true"/>
<send/>
</else>
</filter>
</else>
</filter>
<description/>
</sequence>
Class Mediator:
public class JMSStoreMediator extends AbstractMediator implements
ManagedLifecycle {
Connection connection;
public boolean mediate(MessageContext msgCtx) {
try {
boolean topic=false;
String jmsuri=""+msgCtx.getProperty("jmsuri");
String t=""+msgCtx.getProperty("topic");
if(t.isEmpty()){
topic=false;
}
else {
topic=Boolean.valueOf(t);
}
ConnectionFactory factory= new ActiveMQConnectionFactory(jmsuri);
connection = factory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination=null;
if(!topic)destination= session.createQueue(""+msgCtx.getProperty("jmsqueue"));
else destination= session.createTopic(""+msgCtx.getProperty("jmsqueue"));
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.PERSISTENT);
String xml = ""+msgCtx.getEnvelope().getBody().toStringWithConsume();
if(topic){
JSONObject obj=XML.toJSONObject(xml);
JSONObject ar=obj.getJSONObject("soapenv:Body");
ar.remove("xmlns:soapenv");
xml=ar.toString();
}
TextMessage message = session.createTextMessage(xml);
producer.send(message);
} catch (Exception e) {
log.info("LogLocation = "+getClass().getName()+",Error in storing message in JMS stacktrace is :"+e.toString());
((Axis2MessageContext) msgCtx).setProperty(NhttpConstants.HTTP_SC, 500);
handleException("Error while storing in the message store", msgCtx);
}
finally {
try {
connection.close();
} catch (JMSException e) {
log.info("LogLocation = "+getClass().getName()+",Error in closing JMS connection stacktrace is :"+e.toString());
}
}
log.info("LogLocation = "+getClass().getName()+",ProxyName = "+msgCtx.getProperty("proxy.name")+
",Usercode = "+msgCtx.getProperty("usercode")+",Clientid = "+msgCtx.getProperty("clientid")+
",requestMsgId = "+msgCtx.getProperty("requestMsgId")+",Position = END");
return true;
}
You should share your proxys conf but you can always verify that :
You've set the cachelevel to avoid new connections at each scan : <parameter name="transport.jms.CacheLevel">consumer</parameter>
You've asked to consume all messages a each scan : <parameter name="transport.jms.MaxMessagesPerTask">-1</parameter>
Hi I have the source view of my api from APIM and modified it to get the the htttp header "Authorization" and log it to the log file I added 2 entries in code one for insequence and one for outsequence. In the insequence I added the line
<property name="AuthHeader" expression="$trp:Authorization"/>
In order to get the header and assign it to a property. In the out sequence I added
<log level="custom">
<property name="AuthHeader value" expression="get-property('AuthHeader')"/>
</log>
To determine if the AuthHeader property will display and get the header, however inside the log file it was said that
TID: [0] [AM] [2014-11-19 04:23:01,997] INFO {org.apache.synapse.mediators.builtin.LogMediator} - AuthHeader value = null {org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [AM] [2014-11-19 04:23:07,335] INFO {org.apache.synapse.mediators.builtin.LogMediator} - AuthHeader value = null {org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [AM] [2014-11-19 04:56:17,177] INFO {org.apache.synapse.mediators.builtin.LogMediator} - AuthHeader value = null {org.apache.synapse.mediators.builtin.LogMediator}
Which means I'm not getting the correct http header value, is there something wrong with the code? Please help, the complete API code is below.
Thanks,
Drew
<api name="admin--fte" context="/fte">
<resource methods="POST GET DELETE OPTIONS PUT" url-mapping="/*">
<inSequence>
<property name="AuthHeader" expression="$trp:Authorization"/>
<property name="isDefault" expression="get-property('transport', 'WSO2_AM_API_DEFAULT_VERSION')"/>
<filter source="get-property('isDefault')" regex="true">
<then>
<log level="custom">
<property name="STATUS" value="Faulty invoking through default API.Dropping message to avoid recursion.."/>
</log>
<payloadFactory media-type="xml">
<format>
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>500</am:code>
<am:type>Status report</am:type>
<am:message>Internal Server Error</am:message>
<am:description>Faulty invoking through default API</am:description>
</am:fault>
</format>
<args/>
</payloadFactory>
<property name="HTTP_SC" value="500" scope="axis2"/>
<property name="RESPONSE" value="true"/>
<header name="To" action="remove"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
<property name="ContentType" scope="axis2" action="remove"/>
<property name="Authorization" scope="transport" action="remove"/>
<property name="Host" scope="transport" action="remove"/>
<property name="Accept" scope="transport" action="remove"/>
<send/>
</then>
<else>
<header name="WSO2_AM_API_DEFAULT_VERSION" scope="transport" value="true"/>
<property name="uri.var.portnum" expression="get-property('http.nio.port')"/>
<send>
<endpoint>
<http uri-template="http://localhost:{uri.var.portnum}/fte/1.0">
<timeout>
<duration>30000</duration>
<responseAction>fault</responseAction>
</timeout>
<suspendOnFailure>
<errorCodes>-1</errorCodes>
<initialDuration>0</initialDuration>
<progressionFactor>1.0</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<errorCodes>-1</errorCodes>
</markForSuspension>
</http>
</endpoint>
</send>
</else>
</filter>
</inSequence>
<outSequence>
<property name="messageType" value="application/json" scope="axis2" type="STRING"/>
<log level="custom">
<property name="AuthHeader value" expression="get-property('AuthHeader')"/>
</log>
<send/>
</outSequence>
</resource>
<handlers>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.common.SynapsePropertiesHandler"/>
</handlers>
</api>
By default, the Authorization header is removed by the Authentication handler. That's why you cant' seem to access it or log it. Handlers act before the mediation inSequence.
The Authentication header can be preserved by editing the api-manager.xml config file in /repository/conf. Simply uncomment the following node and change the value to false:
<RemoveOAuthHeadersFromOutMessage>false</RemoveOAuthHeadersFromOutMessage>