How to transfer MDC via gelf to graylog? - log4j2

We have a logging flow where our java application fills an MDC which is transferred via log4j2 to syslog to a central rsyslog installation. Here we make extensive use of MDC. Our setup is thus:
<Syslog name="syslog" format="RFC5424" host="localhost" port="514" protocol="UDP"
appName="messaging_platform.${application}" mdcId="mdc" includeMDC="true" facility="LOCAL5" connectTimeoutMillis="100" ignoreExceptions="false">
<LoggerFields>
<KeyValuePair key="class" value="%c"/>
<KeyValuePair key="classname" value="%c{1}"/>
<KeyValuePair key="exception" value="%ex{full}"/>
<KeyValuePair key="method" value="%method"/>
<KeyValuePair key="line" value="%line"/>
<KeyValuePair key="application_name" value="${application}"/>
<KeyValuePair key="sequenceNumber" value="%sequenceNumber"/>
<KeyValuePair key="application_version" value="${application.version}"/>
<KeyValuePair key="marker" value="%marker"/>
<KeyValuePair key="thread" value="%thread"/>
<KeyValuePair key="system_nano_time" value="%nano"/>
<KeyValuePair key="app_uptime" value="%relative"/>
</LoggerFields>
</Syslog>
I'm trying to convert this to use graylog and it seems GELF is the recommended transport protocol for that. I've found multiple libraries to do this and started with the build-in GelfLayout of log4j2. But that does not support LoggerFields.
So what's the recommended way to get these fields into Graylog? If I do
<Socket name="Graylog" protocol="udp" host="localhost" port="12201">
<GelfLayout host="localhost" compressionType="GZIP" compressionThreshold="1024">
<KeyValuePair key="class" value="%c"/>
<KeyValuePair key="classname" value="%c{1}"/>
<KeyValuePair key="exception" value="%ex{full}"/>
<KeyValuePair key="method" value="%method"/>
<KeyValuePair key="line" value="%line"/>
<KeyValuePair key="application_name" value="${application}"/>
<KeyValuePair key="sequenceNumber" value="%sequenceNumber"/>
<KeyValuePair key="application_version" value="${application.version}"/>
<KeyValuePair key="marker" value="%marker"/>
<KeyValuePair key="thread" value="%thread"/>
<KeyValuePair key="system_nano_time" value="%nano"/>
<KeyValuePair key="app_uptime" value="%relative"/>
</GelfLayout>
</Socket>
I get a bunch of fields in Graylog but the values are not expanded.

I found a solution with logstash-gelf:
<Gelf name="gelf" host="udp:localhost" port="12201" version="1.1" extractStackTrace="true"
filterStackTrace="true" mdcProfiling="true" includeFullMdc="true" maximumMessageSize="8192"
originHost="%host{fqdn}">
<Field name="class" pattern="%c"/>
<Field name="classname" pattern="%c{1}"/>
<Field name="exception" pattern="%ex{full}"/>
<Field name="method" pattern="%method"/>
<Field name="line" pattern="%line"/>
<Field name="application_name" pattern="${application}"/>
<Field name="sequenceNumber" pattern="%sequenceNumber"/>
<Field name="application_version" pattern="${application.version}"/>
<Field name="marker" pattern="%marker"/>
<Field name="thread" pattern="%thread"/>
<Field name="system_nano_time" pattern="%nano"/>
<Field name="app_uptime" pattern="%relative"/>
<Field name="severity" pattern="%level{WARN=Warning, DEBUG=Debug, ERROR=Error, TRACE=Trace, INFO=Info}"/>
</Gelf>

I use logstash-gelf with the following logback configuration;
logback.xml configuration:
<appender name="NameOfAppender" class="biz.paluch.logging.gelf.logback.GelfLogbackAppender">
<host>udp:10.123.33.41</host> <!-- graylog endpoint ip here -->
<port>12201</port> <!-- graylog endpoint port here -->
<version>1.1</version>
<facility>java-prod</facility>
<extractStackTrace>true</extractStackTrace>
<filterStackTrace>true</filterStackTrace>
<mdcProfiling>true</mdcProfiling>
<timestampPattern>yyyy-MM-dd HH:mm:ss,SSSS</timestampPattern>
<maximumMessageSize>8192</maximumMessageSize>
<additionalFields>Env=prod,Operation=INTG_PERF</additionalFields>
<!-- This are fields using MDC -->
<mdcFields>RequestTime,ResponseTime,ElapsedTime,ServiceType,ServiceIdentifier,Endpoint,Method,Status</mdcFields>
<dynamicMdcFields>mdc.*,(mdc|MDC)fields</dynamicMdcFields>
<includeFullMdc>false</includeFullMdc>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
</appender>
<logger name="NameOfLogger" level="INFO">
<appender-ref ref="NameOfAppender" />
</logger>
java logging sample:
org.slf4j.Logger logger = LoggerFactory.getLogger("NameOfLogger");
MDC.put("RequestTime", new Date().toString());
MDC.put("ResponseTime", new Date().toString());
MDC.put("ElapsedTime", "232");
MDC.put("ServiceType", "BANK");
MDC.put("ServiceIdentifier", "XBANK");
MDC.put("Endpoint", "https://www..");
MDC.put("Method", "doSale");
MDC.put("Status", "SUCCEED");
logger.info("WS INTEGRATION PERF");
maven dependency:
<dependency>
<groupId>biz.paluch.logging</groupId>
<artifactId>logstash-gelf</artifactId>
<version>1.11.1</version>
</dependency>

Related

log4j2 TimeBasedTriggeringPolicy not working as expected

I have configured the log4j2.xml file in such a way that application.log file will be created and it should be rollover daily.
<?xml version="1.0" encoding="UTF-8"?>
<!-- ===================================================================== -->
<!-- Log4j2 Configuration -->
<!-- ===================================================================== -->
<Configuration status= "INFO">
<!-- Common properties used in all appenders -->
<Properties>
<Property name="logBaseDirectory">/apps/wsserver/8.5/bpm/logs/log4j/sbl</Property>
<Property name="logPattern">%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{1} %X{transaction.id} %m%n</Property>
<Property name="maxFileAge">90d</Property>
</Properties>
<!-- Define required appenders -->
<Appenders>
<!-- ============================================================================================================================================ -->
<!-- log4j 1.x to 2.x migratoin steps -->
<!-- DailyRollingFileAppender rolling file appender is no longer availble in log4j2. So we need to use RollingFile with TimeBasedTriggeringPolicy -->
<!-- Right most value in filePattern will be considered as Interval for TimeBasedTriggeringPolicy rolling -->
<!-- Orignal log file will be application.log and archive will be application-20200917.log.zip - Auto compression of file -->
<!-- Remove the all archived logs which are older than 90 days -->
<!-- ============================================================================================================================================ -->
<RollingFile name="application" fileName="${logBaseDirectory}/application.log" filePattern="${logBaseDirectory}/application-%d{yyyy-MM-dd}.log.zip">
<PatternLayout pattern="${logPattern}"/>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<SizeBasedTriggeringPolicy />
<CronTriggeringPolicy />
</Policies>
<DefaultRolloverStrategy>
<Delete basePath="${logBaseDirectory}" maxDepth="1">
<IfFileName glob="application-*.log.zip" />
<IfLastModified age="${maxFileAge}" />
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
</Appenders>
<!-- Define the list of loggers required -->
<Loggers>
<logger name="MediationServices" level="TRACE" additivity="false">
<appender-ref ref="application" />
</logger>
<root level="TRACE" additivity="false">
<appender-ref ref="application" />
</root>
</Loggers>
</Configuration>
But in JVM, applicatoin.log file is getting rollover after 10MB and if three times it is rolled, the first file is getting overwritten. That means at any point of time i am having application.log and application-2020-10-16.log.zip.
Why log4j2 (v2.13) is rolling over the files for every 10MB even though configured as daily? Any pointers identifying issue in log4j2 configuration is much apricated.
Issue has been identified. AS <SizeBasedTriggeringPolicy /> is defined in configuration file, log4j2 is considering 10MB default value as file size and getting rollover. After removing this tag, issue has been resolved.

log4j2 DynamicThresholdFilter not picking up property value

Trying to set different printing levels for console and file.
Goal is: when debug=true, print debug level (console & file), else only print error level (console).
Change it programatically like this:
#Override
public void contextInitialized(ServletContextEvent sce) {
ThreadContext.put("debugMode", "true");
}
This is my log4j2 configuration:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="debug">
<Properties>
<Property name="logPath">${sys:catalina.home}</Property>
<Property name="rollingFileName">vsTenant</Property>
</Properties>
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<filters>>
<DynamicThresholdFilter key="debugMode" defaultThreshold="ERROR" onMatch="ACCEPT" onMismatch="NEUTRAL">
<KeyValuePair key="true" value="DEBUG"/>
<KeyValuePair key="false" value="ERROR"/>
</DynamicThresholdFilter>
</filters>
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%thread] %-5level [vsTenant] %logger{36} - %msg\n%n" />
</Console>
<RollingFile name="rollingFile" fileName="${logPath}/logs/vsTenant.log" filePattern="${logPath}/logs/vsTenant_%d{dd-MM-yyyy}.log">
<filters>>
<DynamicThresholdFilter key="debugMode" onMatch="ACCEPT" onMismatch="DENY">
<KeyValuePair key="true" value="DEBUG"/>
</DynamicThresholdFilter>
</filters>
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%thread] %-5level [vsTenant] %logger{36} - %msg\n%n" />
<Policies>
<SizeBasedTriggeringPolicy size="50 MB" />
</Policies>
<DefaultRolloverStrategy max="5"/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="ERROR" additivity="false">
<AppenderRef ref="console" />
<AppenderRef ref="rollingFile" />
</Root>
</Loggers>
</Configuration>
It is always printing ERROR level. Help is appreciated.
You were close, only a few small changes are needed to achieve what you want.
Change the first onMismatch from NEUTRAL to DENY
Add a second KeyValuePair to the second filter: <KeyValuePair key="false" value="OFF"/>
Change the Root log level from ERROR to TRACE
Here's the modified configuration:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn">
<Properties>
<Property name="logPath">${sys:catalina.home}</Property>
<Property name="rollingFileName">vsTenant</Property>
</Properties>
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<filters>
<DynamicThresholdFilter key="debugMode" defaultThreshold="ERROR" onMatch="ACCEPT" onMismatch="DENY">
<KeyValuePair key="true" value="DEBUG"/>
<KeyValuePair key="false" value="ERROR"/>
</DynamicThresholdFilter>
</filters>
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%thread] %-5level [vsTenant] %logger{36} - %msg\n%n" />
</Console>
<RollingFile name="rollingFile" fileName="${logPath}/logs/vsTenant.log" filePattern="${logPath}/logs/vsTenant_%d{dd-MM-yyyy}.log">
<filters>
<DynamicThresholdFilter key="debugMode" onMatch="ACCEPT" onMismatch="DENY">
<KeyValuePair key="true" value="DEBUG"/>
<KeyValuePair key="false" value="OFF"/>
</DynamicThresholdFilter>
</filters>
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%thread] %-5level [vsTenant] %logger{36} - %msg\n%n" />
<Policies>
<SizeBasedTriggeringPolicy size="50 MB" />
</Policies>
<DefaultRolloverStrategy max="5"/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="TRACE" additivity="false">
<AppenderRef ref="console" />
<AppenderRef ref="rollingFile" />
</Root>
</Loggers>
</Configuration>
Here is some java code to test it with:
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.ThreadContext;
public class SomeClass {
private static final Logger log = LogManager.getLogger();
public static void main(String[] args){
ThreadContext.put("debugMode", "false");
log.info("Info should not show anywhere");
log.debug("This shouldn't show anywhere");
ThreadContext.put("debugMode", "true");
log.debug("This should show in the log and console");
log.info("This should also show in both");
ThreadContext.put("debugMode", "false");
log.info("This should not show anywhere");
log.error("This error should show only in console.");
}
}
Running the above will output the following to console:
21:16:40.716 [main] DEBUG [vsTenant] example.SomeClass - This should show in the log and console
21:16:40.718 [main] INFO [vsTenant] example.SomeClass - This should also show in both
21:16:40.718 [main] ERROR [vsTenant] example.SomeClass - This error should show only in console.
and output the following to the log file:
21:16:40.716 [main] DEBUG [vsTenant] example.SomeClass - This should show in the log and console
21:16:40.718 [main] INFO [vsTenant] example.SomeClass - This should also show in both

OpenJPA + Log4j2

Having problem with integrating OpenJPA with log4j2.
OpenJPA + log4j worked fined
<appender name="OPENJPA_LOG" class="org.apache.log4j.RollingFileAppender">
<param name="maxFileSize" value="5MB" />
<param name="maxBackupIndex" value="10" />
<param name="file" value="./logs/openjpa.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c:%L - %m%n" />
</layout>
</appender>
<logger name="openjpa.jdbc.SQL" additivity="false">
<level value="TRACE" />
<appender-ref ref="OPENJPA_LOG" />
</logger>
But it is not working with log4j2.
<RollingFile name="OPENJPA_LOG" fileName="./logs/openjpa.log"
append="true" filePattern="./logs/openjpa.%i.log.gz"
ignoreExceptions="false">
<PatternLayout>
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} - %c [%thread] - %m%n</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="10MB" />
</Policies>
<DefaultRolloverStrategy max="5" />
</RollingFile>
<Logger name="openjpa.jdbc.SQL" level="TRACE" additivity="false" >
<AppenderRef ref="OPENJPA_LOG" />
</Logger>
How to fix it.
If you still have issues with this you have to double check that in the persistence.xml you set <property name="openjpa.Log" value="slf4j"/>.
Indeed open jpa is not compatible with log4j2 natively so if you use <property name="openjpa.Log" value="log4j"/> you will run into a java.lang.ClassNotFoundException: org.apache.log4j.Priority.
Once openjpa logs are route properly to slf4j it is ok. I hope your application use sllf4j.
Be sure to use proper versions of log4j2 slf4j and bridge and remove all previous log4j1.x and old slf4j dependencies.

Log4j2 Different appender for different level

I have a little problem and canĀ“t find a solution. I want to set pattern layout for level info another than for level warn. If I have a log in level INFO everything is OK, but if the log is levelWARN it is written out into console two times (as level info and as level warn). Simply all logs at a specific level is written out us log at that level and the level below.
I want to logs in level INFO write out to console like: "%-5level %d{dd-MM-yyyy HH:mm:ss} %msg%n" and level WARN like "%-5level %d{dd-MM-yyyy HH:mm:ss} [%l] %msg%n".
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Console name="ConsoleInfo" target="SYSTEM_OUT">
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="%-5level %d{dd-MM-yyyy HH:mm:ss} %msg%n"/>
</Console>
<Console name="ConsoleWarning" target="SYSTEM_OUT">
<ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="%-5level %d{dd-MM-yyyy HH:mm:ss} [%l] %msg%n"/>
</Console>
<File name="File" fileName="logs/cli.log">
<PatternLayout pattern="%-5level %d{dd-MM-yyyy HH:mm:ss} [%l] %msg%n"/>
</File>
</Appenders>
<Loggers>
<Root level="ALL">
<AppenderRef ref="ConsoleInfo"/>
<AppenderRef ref="ConsoleWarning"/>
<AppenderRef ref="File"/>
</Root>
</Loggers>
</Configuration>
As I understand it you want to have log events with a level of WARN or higher (WARN,ERROR,FATAL) go to the "ConsoleWarning" appender only rather than going to both "ConsoleWarning" and "ConsoleInfo".
The simplest way to do this would be to modify your filter configuration in your "ConsoleInfo" appender to basically do the opposite approach like this:
<Console name="ConsoleInfo" target="SYSTEM_OUT">
<ThresholdFilter level="WARN" onMatch="DENY" onMismatch="ACCEPT"/>
<PatternLayout pattern="%-5level %d{dd-MM-yyyy HH:mm:ss} %msg%n"/>
</Console>
This works because as the log4j2 manual states:
This filter returns the onMatch result if the level in the LogEvent is the same or more specific than the configured level and the onMismatch value otherwise. For example, if the ThresholdFilter is configured with Level ERROR and the LogEvent contains Level DEBUG then the onMismatch value will be returned since ERROR events are more specific than DEBUG.
This will cause the appender to accept only events that have a level less than WARN.
Another possible solution would be to use a RoutingAppender to specify the destination for each level. If you do it this way then you don't need the ThresholdFilters at all. Also note that you can ignore events of specific levels by not providing a default route and not providing a route for that level. For example, if you remove <Route ref="ConsoleInfo" key="DEBUG" /> from the configuration below then all DEBUG events will be ignored by the routing appender and will not be printed to console. Here is the configuration:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Console name="ConsoleInfo" target="SYSTEM_OUT">
<PatternLayout pattern="%-5level %d{dd-MM-yyyy HH:mm:ss} %msg%n"/>
</Console>
<Console name="ConsoleWarning" target="SYSTEM_OUT">
<PatternLayout pattern="%-5level %d{dd-MM-yyyy HH:mm:ss} [%l] %msg%n"/>
</Console>
<File name="File" fileName="logs/cli.log">
<PatternLayout pattern="%-5level %d{dd-MM-yyyy HH:mm:ss} [%l] %msg%n"/>
</File>
<Routing name="Routing">
<Routes>
<Script name="RoutingInit" language="JavaScript"><![CDATA[
logEvent.getLevel();]]>
</Script>
<Route ref="ConsoleInfo" key="TRACE" />
<Route ref="ConsoleInfo" key="DEBUG" />
<Route ref="ConsoleInfo" key="INFO" />
<Route ref="ConsoleWarning" key="WARN" />
<Route ref="ConsoleWarning" key="ERROR" />
<Route ref="ConsoleWarning" key="FATAL" />
</Routes>
</Routing>
</Appenders>
<Loggers>
<Root level="ALL">
<AppenderRef ref="Routing"/>
<AppenderRef ref="File"/>
</Root>
</Loggers>
</Configuration>
Hope this helps!

How to call Wso2bps using wso2esb

I am using wso2esb4.8.0 and wso2bps3.0.1 while i am working with 2 servers both are working fine .But i wish incorporate both severs for that i written sample BPEL
sample BPLE file is like this
<bpel:process name="multiply2integers"
targetNamespace="http://wso2.org/bps/sample"
suppressJoinFailure="yes"
xmlns:tns="http://wso2.org/bps/sample"
xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
>
<!-- Import the client WSDL -->
<bpel:import location="multiply2integersArtifacts.wsdl" namespace="http://wso2.org/bps/sample"
importType="http://schemas.xmlsoap.org/wsdl/" />
<!-- ================================================================= -->
<!-- PARTNERLINKS -->
<!-- List of services participating in this BPEL process -->
<!-- ================================================================= -->
<bpel:partnerLinks>
<!-- The 'client' role represents the requester of this service. -->
<bpel:partnerLink name="client"
partnerLinkType="tns:multiply2integers"
myRole="multiply2integersProvider"
/>
</bpel:partnerLinks>
<!-- ================================================================= -->
<!-- VARIABLES -->
<!-- List of messages and XML documents used within this BPEL process -->
<!-- ================================================================= -->
<bpel:variables>
<!-- Reference to the message passed as input during initiation -->
<bpel:variable name="input"
messageType="tns:multiply2integersRequestMessage"/>
<!--
Reference to the message that will be returned to the requester
-->
<bpel:variable name="output"
messageType="tns:multiply2integersResponseMessage"/>
</bpel:variables>
<!-- ================================================================= -->
<!-- ORCHESTRATION LOGIC -->
<!-- Set of activities coordinating the flow of messages across the -->
<!-- services integrated within this business process -->
<!-- ================================================================= -->
<bpel:sequence name="main">
<!-- Receive input from requester.
Note: This maps to operation defined in multiply2integers.wsdl
-->
<bpel:receive name="start" partnerLink="client"
portType="tns:multiply2integers"
operation="process" variable="input"
createInstance="yes"/>
<!-- Generate reply to synchronous request -->
<bpel:assign validate="no" name="Assign">
<bpel:copy>
<bpel:from>
<bpel:literal>
<tns:multiply2integersResponse xmlns:tns="http://wso2.org/bps/sample" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><tns:mul>0</tns:mul>
</tns:multiply2integersResponse>
</bpel:literal>
</bpel:from>
<bpel:to variable="output" part="payload"></bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from>
<![CDATA[$input.payload/tns:c*$input.payload/tns:d]]>
</bpel:from>
<bpel:to part="payload" variable="output">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:mul]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:reply name="end"
partnerLink="client"
portType="tns:multiply2integers"
operation="process"
variable="output"
/>
</bpel:sequence>
</bpel:process>
even i am publishing my bpel wsdl also
if i try with wso2bps TRYIT tool its working fine but while calling with wso2esb is not working
WSDL file is
<?xml version="1.0"?>
<definitions name="multiply2integers"
targetNamespace="http://wso2.org/bps/sample"
xmlns:tns="http://wso2.org/bps/sample"
xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TYPE DEFINITION - List of types participating in this BPEL process
The BPEL Designer will generate default request and response types
but you can define or import any XML Schema type and use them as part
of the message types.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<types>
<schema attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://wso2.org/bps/sample"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="multiply2integersRequest">
<complexType>
<sequence>
<element name="c" type="int"/>
<element name="d" type="int"/>
</sequence>
</complexType>
</element>
<element name="multiply2integersResponse">
<complexType>
<sequence>
<element name="mul" type="int"/>
</sequence>
</complexType>
</element>
</schema>
</types>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MESSAGE TYPE DEFINITION - Definition of the message types used as
part of the port type defintions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<message name="multiply2integersRequestMessage">
<part name="payload" element="tns:multiply2integersRequest"/>
</message>
<message name="multiply2integersResponseMessage">
<part name="payload" element="tns:multiply2integersResponse"/>
</message>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PORT TYPE DEFINITION - A port type groups a set of operations into
a logical service unit.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- portType implemented by the multiply2integers BPEL process -->
<portType name="multiply2integers">
<operation name="process">
<input message="tns:multiply2integersRequestMessage" />
<output message="tns:multiply2integersResponseMessage"/>
</operation>
</portType>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PARTNER LINK TYPE DEFINITION
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<plnk:partnerLinkType name="multiply2integers">
<plnk:role name="multiply2integersProvider" portType="tns:multiply2integers"/>
</plnk:partnerLinkType>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BINDING DEFINITION - Defines the message format and protocol details
for a web service.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<binding name="multiply2integersBinding" type="tns:multiply2integers">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="process">
<soap:operation
soapAction="http://wso2.org/bps/sample/process" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SERVICE DEFINITION - A service groups a set of ports into
a service unit.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<service name="multiply2integers">
<port name="multiply2integersPort" binding="tns:multiply2integersBinding">
<soap:address location="http://*********:8080/multiply2integers" />
</port>
</service>
</definitions>
and i written sample proxy which will call the BPEL endpoint that sample proxy define below
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="BPELProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="value1"
expression="//c/text()"
scope="default"
type="STRING"/>
<property name="value2"
expression="//d/text()"
scope="default"
type="STRING"/>
<payloadFactory media-type="xml">
<format>
<p:AddingPLRequest xmlns:p="http://wso2.org/bps/sample">
<c xmlns="http://wso2.org/bps/sample">$1</c>
<d xmlns="http://wso2.org/bps/sample">$2</d>
</p:AddingPLRequest>
</format>
<args>
<arg evaluator="xml" expression="get-property('c')"/>
<arg evaluator="xml" expression="get-property('d')"/>
</args>
</payloadFactory>
<log level="full"/>
<send>
<endpoint key="BPEL"/>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<description/>
</proxy>
defined endpoint view is my endpoint is
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="BPEL">
<address uri="http://*************:9763/services/multiply2integers/" format="soap12">
<suspendOnFailure>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
<retryDelay>0</retryDelay>
</markForSuspension>
</address>
</endpoint>
i am sending request from CURL command to ESB I am getting errors my CURL Command is.
curl -v -H "Accept: application/json" -H "Content-Type:application/json" -d '{"c":"55","d":"3"}' http://***t:8282/services/BPELProxy
and its showing errors if i change the format of endpoint its showing some other error error log like this
[2014-01-13 15:20:01,070] INFO {org.wso2.carbon.core.services.util.CarbonAuthenticationUtil} - 'admin#carbon.super [-1234]' logged in at [2014-01-13 15:20:01,070+0530]
[2014-01-13 15:22:44,887] WARN {org.wso2.carbon.server.admin.module.handler.AuthenticationHandler} - Illegal access attempt at [2014-01-13 15:22:44,0886] from IP address null while trying to authenticate access to service StatisticsAdmin
[2014-01-13 15:22:44,887] ERROR {org.wso2.carbon.statistics.ui.StatisticsAdminClient} - Cannot get service stats for service multiply2integers. Backend server may be unavailable.
org.apache.axis2.AxisFault: The input stream for an incoming message is null.

Resources