This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Item Initiation in eBay

The first use case in the  eBay business scenario is item initiation. This page describes the related tasks and the operations you use in the eBay, TradeGecko, Facebook, and Campaign Monitor connectors. TradeGecko is an inventory control system that you can use to track purchases from suppliers, notify them of new orders, receive invoices, make payments, and automatically import the product data upon receiving them. Facebook can be used to share the promotional items by posting them on the seller’s wall. Campaign Monitor is an email marketing service that you can use to market and promote the items.

Overview

The flow for item initiation is illustrated in the following diagram. The ESB connectors for TradeGecko, Facebook, and Campaign Monitor will be used to connect to each service. 
 

  1. Retrieve the product item's details from TradeGecko using the getProduct operation, and create the item in eBay using the a ddItem operation. 
  2. Convert an item in eBay to a promotional sale item using the setPromotionalSale and setPromotionalSaleListings  operations, and retreive the promotional sale item details from eBay using the getItem operation.
  3. Create a campaign using the createCampaignFromTemplate operation in Campaign Monitor with the promotional details.
  4. Post promotional sale offers on the seller's Facebook wall using the createPost operation. 
  5. Retrieve classified product variant details from TradeGecko using the getProduct  operation, and create the classified ad in eBay with the listing type "Lead Generation" using the a ddItem operation.
TradeGecko operations
eBay operations
Campaign Monitor operations
Facebook operations
Samples
Sample Template for Creating eBay Items According to the Given Parameters
<?xml version="1.0" ?>
<!-- This template creates eBay items according to the given parameters. -->
<template name="ebay-addItemToeBay" xmlns="http://ws.apache.org/ns/synapse">
    <parameter name="apiUrl" description="The URL of the eBay SOAP API."/>
	<parameter name="appId" description="The eBay application ID."/>
	<parameter name="version" description="The eBay request version."/>
	<parameter name="routing" description="The eBay routing."/>
	<parameter name="siteId" description="The site ID of eBay."/>
	<parameter name="authToken" description="The eBay authentication token."/>
	<parameter name="messageId" description="The id of the message."/>
	<parameter name="errorLanguage" description="The error language."/>
	<parameter name="warningLevel" description="The warning level."/>
	<parameter name="title" description="The title of the item"/>
	<parameter name="description" description="The description of the item"/>
	<parameter name="categoryID" description="Category ID of the category the item belongs to."/>
	<parameter name="startPrice" description="The starting price of the item."/>
	<parameter name="conditionId" description="Condition ID for the item."/>
	<parameter name="country" description="The country for the sale."/>
	<parameter name="currency" description="The currency to sell in."/>
	<parameter name="listingDuration" description="The listing duration of the item."/>
	<parameter name="listingType" description="The listing type of the item."/>
	<parameter name="paymentMethods" description="Payment methods for the sale."/>
	<parameter name="paypalEmailAddress" description="The PayPal email address for the account."/>
	<parameter name="pictureUrl" description="The URL to a picture of the item."/>
	<parameter name="postalCode" description="The postal code of the seller."/>
	<parameter name="quantity" description="The quantity of the items to be sold."/>
	<parameter name="returnsAcceptedOption" description="Options for accepting returns."/>
	<parameter name="refundOption" description="The option for refunding on return."/>
	<parameter name="returnsDescription" description="The description for returns."/>
	<parameter name="returnsWithinOption" description="The option for returns within a period of time."/>
	<parameter name="shippingCostPaidByOption" description="The option for selecting who pays returns shipping cost."/>
	<parameter name="shippingType" description="The shipping type for the item."/>
	<parameter name="shippingServicePriority" description="The priority of the shipping service."/>
	<parameter name="shippingService" description="The shipping service name."/>
	<parameter name="shippingServiceCost" description="The cost for the shipping service."/>
	<parameter name="site" description="Site ID to post the item on."/>
	<parameter name="uuid" description="Unique ID for the item."/>
	<parameter name="dispatchTimeMax" description="Handling time" />
	<parameter name="itemSpecifics" description="Item specifications as name value list." />
    <sequence>
    	<property name="uri.var.apiUrl" expression="$func:apiUrl"/>
	    <property name="uri.var.appId" expression="$func:appId"/>
	    <property name="uri.var.version" expression="$func:version"/>
	    <property name="uri.var.routing" expression="$func:routing"/>
	    <property name="uri.var.siteId" expression="$func:siteId"/>
	    <property name="uri.var.authToken" expression="$func:authToken"/>
	    <property name="uri.var.messageId" expression="$func:messageId"/>
	    <property name="uri.var.errorLanguage" expression="$func:errorLanguage"/>
	    <property name="uri.var.warningLevel" expression="$func:warningLevel"/>
	    <property name="uri.var.title" expression="$func:title"/>
	    <property name="uri.var.description" expression="$func:description"/>
	    <property name="uri.var.categoryID" expression="$func:categoryID"/>
	    <property name="uri.var.startPrice" expression="$func:startPrice"/>
	    <property name="uri.var.conditionId" expression="$func:conditionId"/>
	    <property name="uri.var.country" expression="$func:country"/>
	    <property name="uri.var.currency" expression="$func:currency"/>
	    <property name="uri.var.listingDuration" expression="$func:listingDuration"/>
	    <property name="uri.var.listingType" expression="$func:listingType"/>
	    <property name="uri.var.paymentMethods" expression="$func:paymentMethods"/>
	    <property name="uri.var.paypalEmailAddress" expression="$func:paypalEmailAddress"/>
	    <property name="uri.var.pictureUrl" expression="$func:pictureUrl"/>
	    <property name="uri.var.postalCode" expression="$func:postalCode"/>
	    <property name="uri.var.quantity" expression="$func:quantity"/>
	    <property name="uri.var.returnsAcceptedOption" expression="$func:returnsAcceptedOption"/>
	    <property name="uri.var.refundOption" expression="$func:refundOption"/>
	    <property name="uri.var.returnsDescription" expression="$func:returnsDescription"/>
	    <property name="uri.var.returnsWithinOption" expression="$func:returnsWithinOption"/>
	    <property name="uri.var.shippingCostPaidByOption" expression="$func:shippingCostPaidByOption"/>
	    <property name="uri.var.shippingType" expression="$func:shippingType"/>
	    <property name="uri.var.shippingServicePriority" expression="$func:shippingServicePriority"/>
	    <property name="uri.var.shippingService" expression="$func:shippingService"/>
	    <property name="uri.var.shippingServiceCost" expression="$func:shippingServiceCost"/>
	    <property name="uri.var.site" expression="$func:site"/>
	    <property name="uri.var.uuid" expression="$func:uuid"/>
	    <property name="uri.var.dispatchTimeMax" expression="$func:dispatchTimeMax"/>
		<property name="uri.var.itemSpecifics" expression="$func:itemSpecifics"/>
		
		
		<filter  source="boolean(get-property('uri.var.authToken'))" regex="false">
            <then>
                            
				<property name="status" value="Skipped" />
				<property name="message" value="Please provide the eBay AUTH token." />
			
							
            </then>
			<else>
				<!-- Set item payload -->
				<payloadFactory media-type="xml">
					<format>
						<ebl:item xmlns:ebl="urn:ebay:apis:eBLBaseComponents">
							<ebl:values>
								<ebl:Title>$1</ebl:Title>
								<ebl:Description>$2</ebl:Description>
								<ebl:PrimaryCategory>
									<ebl:CategoryID>$3</ebl:CategoryID>
								</ebl:PrimaryCategory>
								<ebl:StartPrice>$4</ebl:StartPrice>
								<ebl:ConditionID>$5</ebl:ConditionID>
								<ebl:Country>$6</ebl:Country>
								<ebl:Currency>$7</ebl:Currency>
								<ebl:ListingDuration>$8</ebl:ListingDuration>
								<ebl:ListingType>$9</ebl:ListingType>
								<ebl:PaymentMethods>$10</ebl:PaymentMethods>
								<ebl:PayPalEmailAddress>$11</ebl:PayPalEmailAddress>
								<ebl:PictureDetails>
									<ebl:PictureURL>$12</ebl:PictureURL>
								</ebl:PictureDetails>
								<ebl:PostalCode>$13</ebl:PostalCode>
								<ebl:Quantity>$14</ebl:Quantity>
								<ebl:ReturnPolicy>
									<ebl:ReturnsAcceptedOption>$15</ebl:ReturnsAcceptedOption>
									<ebl:RefundOption>$16</ebl:RefundOption>
									<ebl:Description>$17</ebl:Description>
									<ebl:ReturnsWithinOption>$18</ebl:ReturnsWithinOption>
									<ebl:ShippingCostPaidByOption>$19</ebl:ShippingCostPaidByOption>
								</ebl:ReturnPolicy>
								<ebl:ShippingDetails>
									<ebl:ShippingType>$20</ebl:ShippingType>
									<ebl:ShippingServiceOptions>
										<ebl:ShippingServicePriority>$21</ebl:ShippingServicePriority>
										<ebl:ShippingService>$22</ebl:ShippingService>
										<ebl:ShippingServiceCost>$23</ebl:ShippingServiceCost>
									</ebl:ShippingServiceOptions>
								</ebl:ShippingDetails>
								<ebl:Site>$24</ebl:Site>
								<ebl:UUID>$25</ebl:UUID>
								<ebl:DispatchTimeMax>$26</ebl:DispatchTimeMax>
								<ebl:ItemSpecifics>$27</ebl:ItemSpecifics>
							</ebl:values>
						</ebl:item>
					</format>
					<args>
						<arg expression="get-property('uri.var.title')"/>
						<arg expression="get-property('uri.var.description')"/>
						<arg expression="get-property('uri.var.categoryID')"/>
						<arg expression="get-property('uri.var.startPrice')"/>
						<arg expression="get-property('uri.var.conditionId')"/>
						<arg expression="get-property('uri.var.country')"/>
						<arg expression="get-property('uri.var.currency')"/>
						<arg expression="get-property('uri.var.listingDuration')"/>
						<arg expression="get-property('uri.var.listingType')"/>
						<arg expression="get-property('uri.var.paymentMethods')"/>
						<arg expression="get-property('uri.var.paypalEmailAddress')"/>
						<arg expression="get-property('uri.var.pictureUrl')"/>
						<arg expression="get-property('uri.var.postalCode')"/>
						<arg expression="get-property('uri.var.quantity')"/>
						<arg expression="get-property('uri.var.returnsAcceptedOption')"/>
						<arg expression="get-property('uri.var.refundOption')"/>
						<arg expression="get-property('uri.var.returnsDescription')"/>
						<arg expression="get-property('uri.var.returnsWithinOption')"/>
						<arg expression="get-property('uri.var.shippingCostPaidByOption')"/>
						<arg expression="get-property('uri.var.shippingType')"/>
						<arg expression="get-property('uri.var.shippingServicePriority')"/>
						<arg expression="get-property('uri.var.shippingService')"/>
						<arg expression="get-property('uri.var.shippingServiceCost')"/>
						<arg expression="get-property('uri.var.site')"/>
						<arg expression="get-property('uri.var.uuid')"/>
						<arg expression="get-property('uri.var.dispatchTimeMax')"/>
						<arg expression="get-property('uri.var.itemSpecifics')" evaluator="xml"/>
					</args>
				</payloadFactory>
				<property name="uri.var.item" expression="//ebl:item/*"  xmlns:ebl="urn:ebay:apis:eBLBaseComponents"/>
				<ebay.init-trading>
					<apiUrl>{$ctx:uri.var.apiUrl}</apiUrl>
					<appId>{$ctx:uri.var.appId}</appId>
					<routing>{$ctx:uri.var.routing}</routing>
					<authToken>{$ctx:uri.var.authToken}</authToken>
					<siteId>{$ctx:uri.var.siteId}</siteId>
					<warningLevel>{$ctx:uri.var.warningLevel}</warningLevel>
					<messageId>{$ctx:uri.var.messageId}</messageId>
					<errorLanguage>{$ctx:uri.var.errorLanguage}</errorLanguage>
					<version>{$ctx:uri.var.version}</version>
				</ebay.init-trading>
				<ebay.addItem>
					<item>{$ctx:uri.var.item}</item>
					<detailLevel>{$ctx:uri.var.detailLevel}</detailLevel>
				</ebay.addItem>
				<property name="messageType" value="application/json" scope="axis2"/>
				<property name="ebayItemId" expression="json-eval($.Envelope.Body.AddItemResponse.ItemID)" />
							
				<filter  source="boolean(get-property('ebayItemId'))" regex="false">
					<then>
					
						<property name="status" value="Error" />
						<property name="message" expression="json-eval($.Envelope.Body.)" />
						
					</then>
					<else>
										
						<property name="status" value="Success" />
						<property name="message" expression="fn:concat('Item created successfully in eBay with the Item Id ',get-property('ebayItemId'),'.')" />
					</else>
				</filter>
			</else>
		</filter>
		
    </sequence>
</template>

 

Sample Proxy for Creating eBay items
<?xml version="1.0" ?>
<proxy name="ebay_retrieveAndCreateItem" startOnLoad="true" statistics="disable" trace="disable" transports="https,http" xmlns="http://ws.apache.org/ns/synapse">
    <target>
        <inSequence onError="faultHandlerSeq">
            <property name="tradegeckoApiUrl" expression="json-eval($.tradegeckoApiUrl)" />
            <property name="tradegeckoAccessToken" expression="json-eval($.tradegeckoAccessToken)" />
            <property name="ebayApiUrl" expression="json-eval($.ebayApiUrl)" />
            <property name="ebayAppId" expression="json-eval($.ebayAppId)" />
            <property name="ebayVersion" expression="json-eval($.ebayVersion)" />
            <property name="ebayRouting" expression="json-eval($.ebayRouting)" />
            <property name="ebaySiteId" expression="json-eval($.ebaySiteId)" />
            <property name="ebayAuthToken" expression="json-eval($.ebayAuthToken)" />
            <property name="ebayMessageId" expression="json-eval($.ebayMessageId)" />
            <property name="ebayErrorLanguage" expression="json-eval($.ebayErrorLanguage)" />
            <property name="ebayWarningLevel" expression="json-eval($.ebayWarningLevel)" />
            <property name="productCount" expression="count(//items/data)" scope="operation" />
			<property name="responseString" value="" scope="operation"/>
            <property name="productIndex" value="0"  scope="operation" />            
			<!--FOR EACH Product : BEGIN-->
             <iterate continueParent="true" id="variants" expression="//items/data" sequential="true">
                <target>
                  <sequence>
                    <property name="variantId" expression="//data/tradegeckoVariantId/text()" />                    
                    <property name="ebayCategoryId" expression="//data/ebayProductDetails/categoryId/text()" />
                    <property name="ebayConditionId" expression="//data/ebayProductDetails/conditionId/text()" />
                    <property name="ebayCountry" expression="//data/ebayProductDetails/country/text()" />
                    <property name="ebayCurrency" expression="//data/ebayProductDetails/currency/text()" />
                    <property name="ebayPictureUrlBackup" expression="//data/ebayProductDetails/pictureUrl/text()" />
                    <property name="ebayListingDuration" expression="//data/ebayProductDetails/listingDuration/text()" />
                    <property name="ebayListingType" expression="//data/ebayProductDetails/listingType/text()" />
                    <property name="ebayPaymentMethods" expression="//data/ebayProductDetails/paymentMethods/text()" />
                    <property name="ebayPaypalEmailAddress" expression="//data/ebayProductDetails/paypalEmailAddress/text()" />
                    <property name="ebayPostalCode" expression="//data/ebayProductDetails/postalCode/text()" />
                    <property name="ebayReturnsAcceptedOption" expression="//data/ebayProductDetails/returnsAcceptedOption/text()" />
                    <property name="ebayRefundOption" expression="//data/ebayProductDetails/refundOption/text()" />
                    <property name="ebayReturnsDescription" expression="//data/ebayProductDetails/returnsDescription/text()" />
                    <property name="ebayReturnsWithinOption" expression="//data/ebayProductDetails/returnsWithinOption/text()" />
                    <property name="ebayShippingCostPaidByOption" expression="//data/ebayProductDetails/shippingCostPaidByOption/text()" />
                    <property name="ebayShippingType" expression="//data/ebayProductDetails/shippingType/text()" />
                    <property name="ebayShippingServicePriority" expression="//data/ebayProductDetails/shippingServicePriority/text()" />
                    <property name="ebayShippingService" expression="//data/ebayProductDetails/shippingService/text()" />
                    <property name="ebayShippingServiceCost" expression="//data/ebayProductDetails/shippingServiceCost/text()" />
                    <property name="ebaySite" expression="//data/ebayProductDetails/site/text()" />
                    <property name="ebayUuid" expression="//data/ebayProductDetails/uuid/text()" />
                    <property name="ebayDispatchTimeMax" expression="//data/ebayProductDetails/dispatchTimeMax/text()" /> 
					<property name="id" expression="fn:concat('variant_id:',get-property('variantId'))" />
					<filter  source="boolean(get-property('variantId'))" regex="false">
                        <then>                            
							<property name="status" value="Error" />
							<property name="message" value="Please provide TradeGecko Variant Id." />							
                        </then>
						<else>                    
							<tradegecko.init>
							  <apiUrl>{$ctx:tradegeckoApiUrl}</apiUrl>
							  <accessToken>{$ctx:tradegeckoAccessToken}</accessToken>
							</tradegecko.init>
							<tradegecko.getProduct>
								<id>{$ctx:variantId}</id>
								<getProductBy>variantId</getProductBy>
							</tradegecko.getProduct>							
							<!-- remove TradeGecko Response Headers -->
							<sequence key="tradegecko-removeResponseHeaders" />							
							<property  name="variantDetails" expression="json-eval($.variant)"/>							
							<!-- if variant details are not available at TreadGecko -->
							<filter  source="boolean(get-property('variantDetails'))" regex="false">
								<then>
									<filter source="$axis2:HTTP_SC" regex="401">
										<then>
											<property name="status" value="Error" />
											<property name="message" value="Invalid access token."  />
										</then>
										<else>
											<property name="status" value="Error" />
											<property name="message" expression="json-eval($.)"  />
										</else>
									</filter>									
								</then>
								<else>
									<property name="tradegeckoProductId" expression="json-eval($.variant.product_id)" />
									<property name="ebayTitle" expression="json-eval($.variant.name)" />
									<property name="ebayDescription" expression="json-eval($.variant.description)" />
									<property name="ebayQuantity" expression="json-eval($.variant.stock_on_hand)" />
									<property name="ebayStartPrice" expression="json-eval($.variant.retail_price)" />
									<script language="js">
									<![CDATA[     
										var jsonPayload=mc.getPayloadJSON();
										var optVal={};
										optVal['opt1'] = jsonPayload.variant.opt1;
										optVal['opt2'] = jsonPayload.variant.opt2;
										optVal['opt3'] = jsonPayload.variant.opt3;										
										mc.setProperty('optVal',optVal);											
									]]>
									</script>
									<tradegecko.init>
										<apiUrl>{$ctx:tradegeckoApiUrl}</apiUrl>
										<accessToken>{$ctx:tradegeckoAccessToken}</accessToken>
									</tradegecko.init>
									<tradegecko.getProduct>
										<id>{$ctx:tradegeckoProductId}</id>
										<getProductBy>productid</getProductBy>
									</tradegecko.getProduct>									
									<!-- remove TradeGecko Response Headers -->
									<sequence key="tradegecko-removeResponseHeaders" />									
									<script language="js">
									<![CDATA[     
										var jsonPayload=mc.getPayloadJSON();
										var optVal=mc.getProperty('optVal');
										var nameValueList = "";										
										var opt={};
										opt['opt1'] = jsonPayload.product.opt1;
										opt['opt2'] = jsonPayload.product.opt2;
										opt['opt3'] = jsonPayload.product.opt3;										
										for (var key in opt) {
											var optName=opt[key];
											var optValue=optVal[key];
											if(optName != null && optName !='' && optValue != null && optValue !=''){												
												nameValueList +="<ebl:NameValueList xmlns:ebl='urn:ebay:apis:eBLBaseComponents'><ebl:Name>"+optName+"</ebl:Name><ebl:Value>"+optValue+"</ebl:Value></ebl:NameValueList>";
											}
										}			
										mc.setProperty('itemSpecifics',nameValueList);								
										]]>
									</script>									
									<!-- remove TradeGecko Response Headers -->
									<sequence key="tradegecko-removeResponseHeaders" />									
									<property name="ebayPictureUrl" expression="json-eval($.product.image_url)" />									
									<filter xpath="get-property('ebayPictureUrl')!='null'">
										<then>
											<property name="ebayPictureUrl" expression="fn:concat('http://',fn:substring-after(get-property('ebayPictureUrl'),'https://'))" />
										</then>
									  <else>
										<property name="ebayPictureUrl" expression="get-property('ebayPictureUrlBackup')" />
									  </else>
									</filter>				
									<call-template target="ebay-addItemToeBay">
									   <!-- parameter values will be passed on to a sequence template -->
									   (
									   <with-param name="apiUrl" value="{$ctx:ebayApiUrl}" /> |
									   <with-param name="appId" value="{$ctx:ebayAppId}" /> |
									   <with-param name="version" value="{$ctx:ebayVersion}" /> |
									   <with-param name="routing" value="{$ctx:ebayRouting}" /> |
									   <with-param name="siteId" value="{$ctx:ebaySiteId}" /> |
									   <with-param name="authToken" value="{$ctx:ebayAuthToken}" /> |
									   <with-param name="messageId" value="{$ctx:ebayMessageId}" /> |
									   <with-param name="errorLanguage" value="{$ctx:ebayErrorLanguage}" /> |
									   <with-param name="warningLevel" value="{$ctx:ebayWarningLevel}" /> |
									   <with-param name="title" value="{$ctx:ebayTitle}" /> |
									   <with-param name="description" value="{$ctx:ebayDescription}" /> |
									   <with-param name="categoryID" value="{$ctx:ebayCategoryId}" /> |
									   <with-param name="startPrice" value="{$ctx:ebayStartPrice}" /> |
									   <with-param name="conditionId" value="{$ctx:ebayConditionId}" /> |
									   <with-param name="country" value="{$ctx:ebayCountry}" /> |
									   <with-param name="currency" value="{$ctx:ebayCurrency}" /> |
									   <with-param name="listingDuration" value="{$ctx:ebayListingDuration}" /> |
									   <with-param name="listingType" value="{$ctx:ebayListingType}" /> |
									   <with-param name="paymentMethods" value="{$ctx:ebayPaymentMethods}" /> |
									   <with-param name="paypalEmailAddress" value="{$ctx:ebayPaypalEmailAddress}" /> |
									   <with-param name="pictureUrl" value="{$ctx:ebayPictureUrl}" /> |
									   <with-param name="postalCode" value="{$ctx:ebayPostalCode}" /> |
									   <with-param name="quantity" value="{$ctx:ebayQuantity}" /> |
									   <with-param name="returnsAcceptedOption" value="{$ctx:ebayReturnsAcceptedOption}" /> |
									   <with-param name="refundOption" value="{$ctx:ebayRefundOption}" /> |
									   <with-param name="returnsDescription" value="{$ctx:ebayReturnsDescription}" /> |
									   <with-param name="returnsWithinOption" value="{$ctx:ebayReturnsWithinOption}" /> |
									   <with-param name="shippingCostPaidByOption" value="{$ctx:ebayShippingCostPaidByOption}" /> |
									   <with-param name="shippingType" value="{$ctx:ebayShippingType}" /> |
									   <with-param name="shippingServicePriority" value="{$ctx:ebayShippingServicePriority}" /> |
									   <with-param name="shippingService" value="{$ctx:ebayShippingService}" /> |
									   <with-param name="shippingServiceCost" value="{$ctx:ebayShippingServiceCost}" /> |
									   <with-param name="site" value="{$ctx:ebaySite}" /> |
									   <with-param name="uuid" value="{$ctx:ebayUuid}" /> |
									   <with-param name="dispatchTimeMax" value="{$ctx:ebayDispatchTimeMax}" /> |
									   <with-param name="itemSpecifics" value="{$ctx:itemSpecifics}" /> |
									   ) *
									</call-template>	
								</else>						
							</filter>
						</else>
					</filter>
					<!-- Call to responseHandlerTemplate after each iteration --> 
					<call-template target="responseHandlerTemplate">
							<with-param name="id" value="{$ctx:id}" />
							<with-param name="status" value="{$ctx:status}" />
							<with-param name="message" value="{$ctx:message}" />
					</call-template>
                    <property name="productIndex" expression="get-property('operation','productIndex') + 1" scope="operation" />                   
                  </sequence>
                </target>
            </iterate>         
			<filter xpath="get-property('operation','productCount') = get-property('operation','productIndex')">
				<then>
					<loopback />
				</then>
			</filter>
        </inSequence>
        <outSequence>
          <property name="messageType" value="application/json" scope="axis2"/>      
		<payloadFactory media-type="json">
            <format>
				{
				"Response":{
					"process":"ebay_retrieveAndCreateItem",
					"activityResponse":[$1]
				}
				}
			</format>
            <args>			
                <arg evaluator="xml" expression="get-property('operation', 'responseString')"/>
            </args>
        </payloadFactory>		
        <send/>
        </outSequence>
    </target>
</proxy>                                                                                   
Sample Request for Creating eBay items
{
	"tradegeckoApiUrl" : "https://api.tradegecko.com",
	"tradegeckoAccessToken" : "78d3a042401cce3fb8ce37542e429a45dbd6b30ed1c6c93c669c4bae03ea6d03",
	"items" : { "data" :[
					{
						"tradegeckoVariantId"	: "3747759",
						"ebayProductDetails"	: {
									"categoryId" 				: "377",
									"conditionId" 				: "1000",
									"country" 					: "US",
									"currency" 					: "USD",
									"listingType"				: "FixedPriceItem",
									"dispatchTimeMax"			: "3",
									"listingDuration" 			: "Days_7",
									"paymentMethods"			: "PayPal",
									"paypalEmailAddress"		: "wso2connector@gmail.com",
									"pictureUrl"				: "http://i1.sandbox.ebayimg.com/03/i/00/6b/63/03_1.JPG?set_id=8800005007",
									"postalCode"				: "95125",
									"returnsAcceptedOption"		: "ReturnsAccepted",
									"refundOption"				: "MoneyBack",
									"returnsDescription"		: "Return Item only if damaged.",
									"returnsWithinOption"		: "Days_30",
									"shippingCostPaidByOption" 	: "Buyer",
									"shippingType"				: "Flat",
									"shippingServicePriority"	: "1",
									"shippingService"			: "USPSMedia",
									"shippingServiceCost"		: "2.00",
									"site"						: "US",
									"uuid"						: "c24fd1ea6a7a47c8a243d797c7bddddd"
								}  		
					},
					{
						"tradegeckoVariantId"	: "3747757",
						"ebayProductDetails"	: {
									"categoryId" 				: "377",
									"startPrice" 				: "10.00",
									"conditionId" 				: "1000",
									"country" 					: "US",
									"currency" 					: "USD",
									"listingType"				: "FixedPriceItem",
									"dispatchTimeMax"			: "3",
									"listingDuration" 			: "Days_7",
									"paymentMethods"			: "PayPal",
									"paypalEmailAddress"		: "wso2connector@gmail.com",
									"pictureUrl"				: "http://i1.sandbox.ebayimg.com/03/i/00/6b/63/03_1.JPG?set_id=8800005007",
									"postalCode"				: "95125",
									"returnsAcceptedOption"		: "ReturnsAccepted",
									"refundOption"				: "MoneyBack",
									"returnsDescription"		: "Return Item only if damaged.",
									"returnsWithinOption"		: "Days_30",
									"shippingCostPaidByOption" 	: "Buyer",
									"shippingType"				: "Flat",
									"shippingServicePriority"	: "1",
									"shippingService"			: "USPSMedia",
									"shippingServiceCost"		: "2.00",
									"site"					: "US",
									"uuid"					: "c24fd1ea6a7a47c8a243d797c7bfdddd"
								}
						}
				]
		},
	"ebayApiUrl" : "https://api.sandbox.ebay.com/wsapi",
	"ebayAuthToken" : "AgAAAA**AQAAAA**aAAAAA**lXzgUw**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wFk4GhDJWLowmdj6x9nY+seQ**VPkCAA**AAMAAA**x9umxS4e6RYDx2DT56ufBcZ+QI+deNI4+Eb78MmDsW57egJgGVTx7vUXRygKTlIQOmNbMyh4cNSwAYFz2q896JZ5f5xxjInZiJqPk+rlmgvN3rqgKYDSS4t0tjmD/UrcPXGYeqNViZIvyYWq0SW67wsvNQTI0IAr3h6So3QcTOR9NPr+lKgQixYzWPrP2Xuy+XkuGraWP5zcNOF0hrKu9iUmSYO8/DgfhGXsfBsamGDTh3vRlltEcDzKNV4RznNudC/eBt4cmB271EppOT16N7NaYXoQ0zwiBZHOrsYvOm3ae36Rjbdo/k94Nd61gBSbnt3U2QFn6I9D2pZ1FFATMXiCiPoXPL2v20f+ZzZX0cTostBZmYDJn1XwiXAnFH+km7Emb91atesP1F22nmzKbP4hIJch86Ll515/wsoVPf7AMxwtUn0s75jeqX/LGpQUSXLL0JPQZPWpanz1q58r+7NwQza9fGHPHzia3kfVd+11UnTomxK1U66IVPmVeyyVe7z9vYTqvD+PzKVCWFqLMooa/Q1KjwbHcFsOnBTGLnoLTqK21t6GQsmkbPnYrNiWpfzd+NGWG/3WajNn7nTtvOS1MBFBaJm2sw6SqAxuINSPv1Rr/8o4W7YWJdN6YiB7VbY/Xml6dO+GF47ePQm1x4su5DrrgpVc9H3FwqpJEE+XJ2qlY2OfrguxGbQK/Xqr85ExXujxxDb/YIbOnHCKi+DNfjO9Z4Nbv6QZHsXbopl9UbPqj0zHhbdvM8dUh8BJ",
	"ebaySiteId" : "0",
	"ebayVersion" : "843", 
	"ebayAppId" : "Virtusa37-a57a-43a3-8f97-fa1e9e2f195",
	"ebayRouting" : "default",
	"ebayWarningLevel" : "",
	"ebayErrorLanguage" : "en_US"	
Sample Template for Creating a Campaign in Campaign Monitor and Creating a Wall Post in Facebook According to the Given Access Token of Campaign Monitor and Facebook with Other Parameters
<?xml version="1.0" ?>
<!-- This template is responsible for creating a campaign in Campaign Monitor and creating a wall post in Facebook 
     according to the given access token of Campaign Monitor & Facebook with other parameters. -->
<template name="ebay-publishItemDetailsOnSocialMedia" xmlns="http://ws.apache.org/ns/synapse">
	<!-- Campaign Monitor related template parameters. -->
	<parameter name="cmApiUrl" description="The API URL of Campaign Monitor." />
	<parameter name="cmAccessToken" description="The access token to authorize the requests to Campaign Monitor." />
	<parameter name="cmClientId" description="The ID of the client for whom the campaign should be created." />
	<parameter name="cmName" description="The name of the campaign." />
	<parameter name="cmSubject" description="The subject of the campaign." />
	<parameter name="cmFromName" description="The campaign sender's name." />
	<parameter name="cmFromEmail" description="The campaign sender's email." />
	<parameter name="cmReplyTo" description="The email address to reply for the campaign." />
	<parameter name="cmListIds" description="The list of subscriber IDs." />
	<parameter name="cmSegmentIds" description="The list of segment IDs." />
	<parameter name="cmTemplateId" description="The ID of the template." />
	<parameter name="cmTemplateContent" description="Content of the campaign template." />
	<!-- Facebook related template parameters. -->
	<parameter name="fbApiUrl" description="The API URL of Facebook." />
	<parameter name="fbAccessToken" description="The access token which provides temporary, secure access to Facebook APIs." />
	<parameter name="fbConnection" description="The connection which belongs to an object." />
	<parameter name="fbMessageBody" description="The main message body of the post." />
	<parameter name="fbLink" description="The URL of a link to attach to the post." />
	<parameter name="fbPicture" description="Determines the preview image associated with the link." />
	<parameter name="fbName" description="Overwrites the title of the link preview." />
	<parameter name="fbCaption" description="Overwrites the caption under the title in the link preview." />
	<parameter name="fbDescription" description="Overwrites the description in the link preview." />
	<parameter name="fbActions" description="The action links attached to the post." />
	<parameter name="fbPlace" description="Page ID of a location associated with this post." />
	<parameter name="fbTags" description="The list of user IDs of people tagged in this post." />
	<parameter name="fbPrivacy" description="Determines the privacy settings of the post." />
	<parameter name="fbObjectAttachment" description="Facebook ID for an existing picture in the person's photo albums to use as the thumbnail image." />
    <sequence>
		<!-- Campaign Monitor related template properties. -->
		<property name="uri.var.cmApiUrl" expression="$func:cmApiUrl"/>
		<property name="uri.var.cmAccessToken" expression="$func:cmAccessToken"/>
		<property name="uri.var.cmClientId" expression="$func:cmClientId"/>
		<property name="uri.var.cmName" expression="$func:cmName"/>
		<property name="uri.var.cmSubject" expression="$func:cmSubject"/>
		<property name="uri.var.cmFromName" expression="$func:cmFromName"/>
		<property name="uri.var.cmFromEmail" expression="$func:cmFromEmail"/>
		<property name="uri.var.cmReplyTo" expression="$func:cmReplyTo"/>
		<property name="uri.var.cmListIds" expression="$func:cmListIds"/>
		<property name="uri.var.cmSegmentIds" expression="$func:cmSegmentIds"/>
		<property name="uri.var.cmTemplateId" expression="$func:cmTemplateId"/>
		<property name="uri.var.cmTemplateContent" expression="$func:cmTemplateContent"/>	
		<!-- Facebook related template properties. -->
		<property name="uri.var.fbApiUrl" expression="$func:fbApiUrl" />
		<property name="uri.var.fbAccessToken" expression="$func:fbAccessToken" />
		<property name="uri.var.fbConnection" expression="$func:fbConnection" />
		<property name="uri.var.fbMessageBody" expression="$func:fbMessageBody" />
		<property name="uri.var.fbLink" expression="$func:fbLink" />
		<property name="uri.var.fbPicture" expression="$func:fbPicture" />
		<property name="uri.var.fbName" expression="$func:fbName" />
		<property name="uri.var.fbCaption" expression="$func:fbCaption" />
		<property name="uri.var.fbDescription" expression="$func:fbDescription" />
		<property name="uri.var.fbActions" expression="$func:fbActions" />
		<property name="uri.var.fbPlace" expression="$func:fbPlace" />
		<property name="uri.var.fbTags" expression="$func:fbTags" />
		<property name="uri.var.fbPrivacy" expression="$func:fbPrivacy" />
		<property name="uri.var.fbObjectAttachment" expression="$func:fbObjectAttachment" />
		<property name="messageType" value="application/json" scope="axis2"/>		
		<!-- If the Campaign Monitor access token is available, proceed with the Campaign Monitor call. -->
		<filter source="boolean(get-property('uri.var.cmAccessToken'))" regex="true">
            <then>           
				<!-- Calling the Campaign Monitor connector. -->
				<campaignmonitor.init>
					<apiUrl>{$ctx:uri.var.cmApiUrl}</apiUrl>
					<accessToken>{$ctx:uri.var.cmAccessToken}</accessToken>
				</campaignmonitor.init>
				<campaignmonitor.createCampaignFromTemplate>
					<clientId>{$ctx:uri.var.cmClientId}</clientId>
					<name>{$ctx:uri.var.cmName}</name>
					<subject>{$ctx:uri.var.cmSubject}</subject>
					<fromName>{$ctx:uri.var.cmFromName}</fromName>
					<fromEmail>{$ctx:uri.var.cmFromEmail}</fromEmail>
					<replyTo>{$ctx:uri.var.cmReplyTo}</replyTo>
					<listIds>{$ctx:uri.var.cmListIds}</listIds>
					<segmentIds>{$ctx:uri.var.cmSegmentIds}</segmentIds>
					<templateId>{$ctx:uri.var.cmTemplateId}</templateId>
					<templateContent>{$ctx:uri.var.cmTemplateContent}</templateContent>
				</campaignmonitor.createCampaignFromTemplate>				
				<!-- Getting the created Campaign ID. -->
				<property name="campaignId" value="" />							
				<!-- According to the successful or unsuccessful response status code, construct the custom messages. -->
				<filter source="$axis2:HTTP_SC" regex="201">
					<then>
						<property name="status" value="Success" />
						<property name="message" expression="fn:concat('Campaign was successfully created with Campaign ID ',get-property('campaignId'),'.')" />
					</then>
					<else>				
						<property name="messageType" value="application/json" scope="axis2"/>
						<property name="status" value="Error" />
						<property name="message" expression="json-eval($.)" />
					</else>
				</filter>
            </then>
		</filter>		
		<!-- If the Facebook access token is available, proceed with the Facebook wall post creation call. -->
		<filter source="boolean(get-property('uri.var.fbAccessToken'))" regex="true">
            <then>           
				<!-- Calling the Facebook connector. -->
				<facebook.init>
					<apiUrl>{$ctx:uri.var.fbApiUrl}</apiUrl>
					<accessToken>{$ctx:uri.var.fbAccessToken}</accessToken>
					<connection>{$ctx:uri.var.fbConnection}</connection> 
				</facebook.init>
				<facebook.createPost> 
					<message>{$ctx:uri.var.fbMessageBody}</message> 
					<link>{$ctx:uri.var.fbLink}</link> 
					<picture>{$ctx:uri.var.fbPicture}</picture>
					<name>{$ctx:uri.var.fbName}</name>
					<caption>{$ctx:uri.var.fbCaption}</caption>
					<description>{$ctx:uri.var.fbDescription}</description>
					<actions>{$ctx:uri.var.fbActions}</actions> 
					<place>{$ctx:uri.var.fbPlace}</place> 
					<tags>{$ctx:uri.var.fbTags}</tags> 
					<privacy>{$ctx:uri.var.fbPrivacy}</privacy> 
					<objectAttachment>{$ctx:uri.var.fbObjectAttachment}</objectAttachment>  
				</facebook.createPost>				
				<!-- Getting the created wall post ID. -->
				<property name="fbPostId" expression="json-eval($.id)" />							
				<!-- According to the availability of the created post ID, construct the custom messages. -->
				<filter source="boolean(get-property('fbPostId'))" regex="true">
					<then>				
						<property name="status" value="Success" />
						<property name="message" expression="fn:concat('Facebook wall post was successfully created with wall post ID ',get-property('fbPostId'),'.')" />
					</then>
					<else>
						<property name="messageType" value="application/json" scope="axis2"/>
						<property name="status" value="Error" />
						<property name="message" expression="json-eval($.)" />
					</else>
				</filter>
            </then>
		</filter>
    </sequence>
</template>
Sample Proxy for Converting eBay Item(s) for Promotional Sale
 
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="ebay_retrieveAndPublishPromotionalDetails"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
      <inSequence onError="faultHandlerSeq">		
        <!-- eBay set promotional sale related properties. -->
		<property name="ebayApiUrl" expression="json-eval($.ebayApiUrl)"/>
        <property name="ebayAppId" expression="json-eval($.ebayAppId)"/>
        <property name="ebayVersion" expression="json-eval($.ebayVersion)"/>
        <property name="ebayRouting" expression="json-eval($.ebayRouting)"/>
        <property name="ebaySiteId" expression="json-eval($.ebaySiteId)"/>
        <property name="ebayAuthToken" expression="json-eval($.ebayAuthToken)"/>
        <property name="ebayMessageId" expression="json-eval($.ebayMessageId)"/>
        <property name="ebayErrorLanguage" expression="json-eval($.ebayErrorLanguage)"/>
        <property name="ebayWarningLevel" expression="json-eval($.ebayWarningLevel)"/>
        <property name="ebayAction" expression="json-eval($.ebayAction)"/>
        <!-- eBay set promotional sale second level properties. -->
        <property name="ebayPromotionalSaleName" expression="json-eval($.ebayPromotionalSaleName)"/>
        <property name="ebayDiscountType" expression="json-eval($.ebayDiscountType)"/>
        <property name="ebayDiscountValue" expression="json-eval($.ebayDiscountValue)"/>
        <property name="ebayPromotionalSaleStartTime" expression="json-eval($.ebayPromotionalSaleStartTime)"/>
        <property name="ebayPromotionalSaleEndTime" expression="json-eval($.ebayPromotionalSaleEndTime)"/>
        <property name="ebayPromotionalSaleType" expression="json-eval($.ebayPromotionalSaleType)"/>
        <!-- eBay set promotional sale listings related properties. -->
        <property name="ebayAllAuctionItems" expression="json-eval($.ebayAllAuctionItems)"/>
        <property name="ebayAllFixedPriceItems" expression="json-eval($.ebayAllFixedPriceItems)"/>
        <property name="ebayAllStoreInventoryItems" expression="json-eval($.ebayAllStoreInventoryItems)"/>
        <property name="ebayCategoryID" expression="json-eval($.ebayCategoryID)"/>
        <property name="ebayStoreCategoryID" expression="json-eval($.ebayStoreCategoryID)"/>
        <property name="ebayPromotionalSaleItemIDArray" expression="json-eval($.ebayPromotionalSaleItemIDArray[*])"/>
        <!-- eBay getItem related properties. -->
        <property name="ebayDetailLevel" expression="json-eval($.ebayDetailLevel)"/>
        <property name="ebayIncludeItemCompatibilityList" expression="json-eval($.ebayIncludeItemCompatibilityList)"/>
        <property name="ebayIncludeItemSpecifics" expression="json-eval($.ebayIncludeItemSpecifics)"/>
        <property name="ebayIncludeTaxTable" expression="json-eval($.ebayIncludeTaxTable)"/>
        <property name="ebayIncludeWatchCount" expression="json-eval($.ebayIncludeWatchCount)"/>
        <property name="ebaySku" expression="json-eval($.ebaySku)"/>
        <property name="ebayTransactionID" expression="json-eval($.ebayTransactionID)"/>
        <property name="ebayVariationSKU" expression="json-eval($.ebayVariationSKU)"/>
        <property name="ebayVariationSpecifics" expression="json-eval($.ebayVariationSpecifics)"/>
        <!-- Campaign Monitor createCampaignFromTemplate related properties. -->
        <property name="cmAccessToken" expression="json-eval($.cmAccessToken)"/>
        <property name="cmApiUrl" expression="json-eval($.cmApiUrl)"/>
        <property name="cmTemplateId" expression="json-eval($.cmTemplateId)"/>
        <property name="cmSegmentIds" expression="json-eval($.cmSegmentIds)"/>
        <property name="cmReplyTo" expression="json-eval($.cmReplyTo)"/>
        <property name="cmSubject" expression="json-eval($.cmSubject)"/>
        <property name="cmName" expression="json-eval($.cmName)"/>
        <property name="cmFromEmail" expression="json-eval($.cmFromEmail)"/>
        <property name="cmListIds" expression="json-eval($.cmListIds)"/>
        <property name="cmFromName" expression="json-eval($.cmFromName)"/>
        <property name="cmClientId" expression="json-eval($.cmClientId)"/>
        <!-- Facebook createPost method related properties. -->
        <property name="fbApiUrl" expression="json-eval($.fbApiUrl)"/>
        <property name="fbAccessToken" expression="json-eval($.fbAccessToken)"/>
        <property name="fbConnection" expression="json-eval($.fbConnection)"/>
        <property name="fbLink" expression="json-eval($.fbLink)"/>
        <property name="fbPicture" expression="json-eval($.fbPicture)"/>
        <property name="fbName" expression="json-eval($.fbName)"/>
        <property name="fbCaption" expression="json-eval($.fbCaption)"/>
        <property name="fbDescription" expression="json-eval($.fbDescription)"/>
        <property name="fbActions" expression="json-eval($.fbActions)"/>
        <property name="fbPlace" expression="json-eval($.fbPlace)"/>
        <property name="fbTags" expression="json-eval($.fbTags)"/>
        <property name="fbPrivacy" expression="json-eval($.fbPrivacy)"/>
        <property name="fbObjectAttachment" expression="json-eval($.fbObjectAttachment)"/>
		<property name="responseString" value="" scope="operation"/>
		<property name="idParam" value="" />	
		<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
<!-- Check whether promotional sale item IDs are provided from the request. -->
		<filter source="boolean(get-property('ebayPromotionalSaleItemIDArray'))" regex="false">
			<then>
				<property name="status" value="Error" />
				<property name="message" value="Please provide at least one promotional sale item ID." />				
				<!-- Calling the response handler template to output the custom error message when promotional items are not provided from the request. -->
				<call-template target="responseHandlerTemplate">
					<with-param name="activity" value="ebay_createPromotionalSale" />
					<with-param name="id" value="{$ctx:idParam}" />
					<with-param name="status" value="{$ctx:status}" />
					<with-param name="message" value="{$ctx:message}" />
				</call-template>				
				<loopback/>
			</then>
			<else>
				<!-- Script mediator to construct the itemID XML array embedded inside the values tag. -->
				<script language="js">
					<![CDATA[						 
						var promotionalSaleItemIDs = mc.getProperty("ebayPromotionalSaleItemIDArray");						
						// Check whether the promotionalSaleItemIDs is a JSON array or not before evaluating the promotionalSaleItemIDArray JSON array.
						if(promotionalSaleItemIDs.charCodeAt(0) != '91' && promotionalSaleItemIDs.charCodeAt(promotionalSaleItemIDs.length-1) != '93'){
							mc.setProperty("isItemArray", "false");
						} else {
							var itemIdArray = eval("(" + promotionalSaleItemIDs + ")");
							var itemIdXmlArray = "<ebl:values xmlns:ebl='urn:ebay:apis:eBLBaseComponents'>";
							var itemsLength = itemIdArray.length;
							//Iterate every item ID received from the request.
							for(var index = 0; index < itemsLength; index++){
								if(itemIdArray[index] != ""){
									var itemId = itemIdArray[index];
									itemIdXmlArray += "<ebl:ItemID xmlns:ebl='urn:ebay:apis:eBLBaseComponents'>" + itemId + "</ebl:ItemID>";
								}
							}							 
							mc.setProperty("itemCount", itemsLength);
							itemIdXmlArray += "</ebl:values>";							 
							//Setting the item ID XML array into a property.
							mc.setProperty("ebayPromotionalSaleItemIDs", itemIdXmlArray);;
						}   
					]]>
				</script>                  
				<!-- Check whether the user has provided a valid JSON array of promotional sale item IDs. -->
				<filter source="get-property('isItemArray')" regex="false">
					<then>
						<property name="status" value="Error" />
						<property name="message" value="Please provide promotional sale item IDs as a JSON array." />
						<!-- Calling the response handler template to output the custom error message when promotional items are not provided from the request. -->
						<call-template target="responseHandlerTemplate">
							<with-param name="activity" value="ebay_createPromotionalSale" />
							<with-param name="id" value="{$ctx:idParam}" />
							<with-param name="status" value="{$ctx:status}" />
							<with-param name="message" value="{$ctx:message}" />
						</call-template>						
						<loopback/>
					</then>
				</filter>
				<!-- Check whether the user provided JSON array of promotional sale item IDs has at least one item. -->
				<filter xpath="get-property('itemCount') = 0">
					<then>
						<property name="status" value="Error" />
						<property name="message" value="Please provide at least one promotional sale item ID." />
						<!-- Calling the response handler template to output the custom error message when promotional items are not provided from the request. -->
						<call-template target="responseHandlerTemplate">
							<with-param name="activity" value="ebay_createPromotionalSale" />
							<with-param name="id" value="{$ctx:idParam}" />
							<with-param name="status" value="{$ctx:status}" />
							<with-param name="message" value="{$ctx:message}" />
						</call-template>						
						<loopback/>
					</then>
					<else>
 					<property name="idParam" expression="fn:concat('{PromotionalSaleItemIDs:',get-property('ebayPromotionalSaleItemIDArray'),'}')"/>
<!-- Creating payload for promotionalSaleDetails using second level properties -->
						<payloadFactory media-type="xml">
							<format>
								<ebl:promotionalSaleDetails xmlns:ebl="urn:ebay:apis:eBLBaseComponents">
									<ebl:values>
										<ebl:PromotionalSaleName>$1</ebl:PromotionalSaleName>
										<ebl:DiscountType>$2</ebl:DiscountType>
										<ebl:DiscountValue>$3</ebl:DiscountValue>
										<ebl:PromotionalSaleStartTime>$4</ebl:PromotionalSaleStartTime>
										<ebl:PromotionalSaleEndTime>$5</ebl:PromotionalSaleEndTime>
										<ebl:PromotionalSaleType>$6</ebl:PromotionalSaleType>
									</ebl:values>
								</ebl:promotionalSaleDetails>
							</format>
							<args>
							  <arg expression="get-property('ebayPromotionalSaleName')" />
							  <arg expression="get-property('ebayDiscountType')" />
							  <arg expression="get-property('ebayDiscountValue')" />
							  <arg expression="get-property('ebayPromotionalSaleStartTime')" />
							  <arg expression="get-property('ebayPromotionalSaleEndTime')" />
							  <arg expression="get-property('ebayPromotionalSaleType')" />
							</args>
						</payloadFactory>
						<!-- Get promotional sale details from the current payload. -->
						<property name="ebayPromotionalSaleDetails" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" expression="//ebl:promotionalSaleDetails/*" />
 						<!-- Setting up an eBay promotional sale without promotional items. -->
						<ebay.init-trading>
							<apiUrl>{$ctx:ebayApiUrl}</apiUrl>
							<appId>{$ctx:ebayAppId}</appId>
							<version>{$ctx:ebayVersion}</version>
							<routing>{$ctx:ebayRouting}</routing>
							<siteId>{$ctx:ebaySiteId}</siteId>
							<authToken>{$ctx:ebayAuthToken}</authToken>
							<messageId>{$ctx:ebayMessageId}</messageId>
							<errorLanguage>{$ctx:ebayErrorLanguage}</errorLanguage>
							<warningLevel>{$ctx:ebayWarningLevel}</warningLevel>
						</ebay.init-trading>
						<ebay.setPromotionalSale>
							<action>{$ctx:ebayAction}</action>
							<promotionalSaleDetails>{$ctx:ebayPromotionalSaleDetails}</promotionalSaleDetails>
						</ebay.setPromotionalSale>
						<!-- Retrieve the acknowledgement code that indicates the response status in setPromotionalSale. -->
						<property name="setPromotionalSaleAck" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" expression="//ebl:Ack/text()"/>
						<!-- Check whether promotional sale creation is unsuccessful before proceeding with other API calls. -->   
						<filter xpath="((get-property('setPromotionalSaleAck') = 'CustomCode') or (get-property('setPromotionalSaleAck') = 'Failure'))">
							<then>
								<property name="messageType" value="application/json" scope="axis2"/>
								<property name="status" expression="get-property('setPromotionalSaleAck')" />
								<property name="message" expression="json-eval($.)" />
								
								<!-- Calling the response handler template to output the unsuccessful message of promotional sale creation. -->
								<call-template target="responseHandlerTemplate">
									<with-param name="activity" value="ebay_createPromotionalSale" />
									<with-param name="id" value="{$ctx:idParam}" />
									<with-param name="status" value="{$ctx:status}" />
									<with-param name="message" value="{$ctx:message}" />
								</call-template>								
								<loopback/>
							</then>
							<else>
								<!-- Retrieve the ID from a successfully created promotional sale. -->
								<property name="ebayPromotionalSaleId" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" expression="//ebl:PromotionalSaleID/text()" />							
								<!-- Get promotional sale item IDs xml array from the ebayPromotionalSaleItemIDs property -->
								<property name="ebayPromotionalSaleItemIDs" expression="get-property('ebayPromotionalSaleItemIDs')" />
<!-- Adding item listings into the created promotional sale in eBay. -->
								<ebay.init-trading>
									<apiUrl>{$ctx:ebayApiUrl}</apiUrl>
									<appId>{$ctx:ebayAppId}</appId>
									<version>{$ctx:ebayVersion}</version>
									<routing>{$ctx:ebayRouting}</routing>
									<siteId>{$ctx:ebaySiteId}</siteId>
									<authToken>{$ctx:ebayAuthToken}</authToken>
									<messageId>{$ctx:ebayMessageId}</messageId>
									<errorLanguage>{$ctx:ebayErrorLanguage}</errorLanguage>
									<warningLevel>{$ctx:ebayWarningLevel}</warningLevel>
								</ebay.init-trading>
								<ebay.setPromotionalSaleListings>
									<action>{$ctx:ebayAction}</action>
									<allAuctionItems>{$ctx:ebayAllAuctionItems}</allAuctionItems>
									<allFixedPriceItems>{$ctx:ebayAllFixedPriceItems}</allFixedPriceItems>
									<allStoreInventoryItems>{$ctx:ebayAllStoreInventoryItems}</allStoreInventoryItems>
									<categoryID>{$ctx:ebayCategoryID}</categoryID>
									<promotionalSaleID>{$ctx:ebayPromotionalSaleId}</promotionalSaleID>
									<promotionalSaleItemIDArray>{$ctx:ebayPromotionalSaleItemIDs}</promotionalSaleItemIDArray>
									<storeCategoryID>{$ctx:ebayStoreCategoryID}</storeCategoryID>
								</ebay.setPromotionalSaleListings>
								<!-- Retrieve the acknowledgement code that indicates the response status of setPromotionalSaleListings in eBay. -->
								<property name="setPromotionalSaleListingsAck" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" expression="//ebl:Ack/text()"/>								
								<!-- Check whether the creation of promotional sale listings is unsuccessful before proceeding with other API calls. -->   
								<filter xpath="((get-property('setPromotionalSaleListingsAck') = 'CustomCode') or (get-property('setPromotionalSaleListingsAck') = 'Failure'))" >
									<then>
										<property name="messageType" value="application/json" scope="axis2"/>
										<property name="status" expression="get-property('setPromotionalSaleListingsAck')" />
										<property name="message" expression="json-eval($.)" />
<!-- Calling the response handler template to output the unsuccessful message of promotional sale listings creation. -->
										<call-template target="responseHandlerTemplate">
											<with-param name="activity" value="ebay_createPromotionalSale" />
											<with-param name="id" value="{$ctx:idParam}" />
											<with-param name="status" value="{$ctx:status}" />
											<with-param name="message" value="{$ctx:message}" />
										</call-template>										
										<loopback/>
									</then>
									<else>
										<!-- Built common message when both operations of setPromotionalSale and setPromotionalSaleListings are successfully processed. -->
										<property name="status" value="Success" />
										<property name="message" expression="fn:concat('Promotional sale items were successfully added to promotional sale with the ID ',get-property('ebayPromotionalSaleId'),'.')" />
<!-- Calling the response handler template to output the successful message of promotional sale listings creation. -->
										<call-template target="responseHandlerTemplate">
											<with-param name="activity" value="ebay_createPromotionalSale" />
											<with-param name="id" value="{$ctx:idParam}" />
											<with-param name="status" value="{$ctx:status}" />
											<with-param name="message" value="{$ctx:message}" />
										</call-template>										
										<!-- Initialize whole items payload with an empty string. -->
										<property name="itemsContent" value="" scope="operation"/>								
										<!-- Initialize a whole item payload with an empty string. -->
										<property name="itemContent" value="" scope="operation"/>										
										<!-- Initialize the Facebook wall post message body with an empty string. -->
										<property name="fbMessageBody" value="" scope="operation"/>										
										<!-- To keep the iterated item index as property. -->
										<property name="itemIndex" value="0" scope="operation"/>										
										<!-- Construct the new payload with item IDs. -->
										<payloadFactory media-type="xml">
											<format>
												<ebl:promotionalSaleItemIDArray xmlns:ebl="urn:ebay:apis:eBLBaseComponents">$1</ebl:promotionalSaleItemIDArray>
											</format>
											<args>
												<arg expression="get-property('ebayPromotionalSaleItemIDs')" />
											</args>
										</payloadFactory>
<!-- Iterate item IDs and get item details for each and every item by passing the item ID -->
										<iterate id="itemIdIterator" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" preservePayload="true" continueParent="true" expression="//ebl:values/*" sequential="true">
											<target>
												<sequence> 
													<property name="ebayItemId" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" expression="//ebl:ItemID/text()"/>												
													<!-- eBay getItem details -->
													<ebay.init-trading>
														<apiUrl>{$ctx:ebayApiUrl}</apiUrl>
														<appId>{$ctx:ebayAppId}</appId>
														<version>{$ctx:ebayVersion}</version>
														<routing>{$ctx:ebayRouting}</routing>
														<siteId>{$ctx:ebaySiteId}</siteId>
														<authToken>{$ctx:ebayAuthToken}</authToken>
														<messageId>{$ctx:ebayMessageId}</messageId>
														<errorLanguage>{$ctx:ebayErrorLanguage}</errorLanguage>
														<warningLevel>{$ctx:ebayWarningLevel}</warningLevel>
													</ebay.init-trading>
													<ebay.getItem>
														<itemId>{$ctx:ebayItemId}</itemId>
														<detailLevel>{$ctx:ebayDetailLevel}</detailLevel>
														<includeItemCompatibilityList>{$ctx:ebayIncludeItemCompatibilityList} </includeItemCompatibilityList>
														<includeItemSpecifics>{$ctx:ebayIncludeItemSpecifics}</includeItemSpecifics>
														<includeTaxTable>{$ctx:ebayIncludeTaxTable}</includeTaxTable>
														<includeWatchCount>{$ctx:ebayIncludeWatchCount}</includeWatchCount>
														<sku>{$ctx:ebaySku}</sku>
														<transactionID>{$ctx:ebayTransactionID}</transactionID>
														<variationSKU>{$ctx:ebayVariationSKU}</variationSKU>
														<variationSpecifics>{$ctx:ebayVariationSpecifics}</variationSpecifics>
													</ebay.getItem>
													<!-- Getting required item details into individual properties to create the draft campaign. -->
													<property name="title" expression="//*[local-name()='Title']" scope="operation"/>
													<property name="viewItemURL" expression="//*[local-name()='ViewItemURL']" scope="operation"/>
													<property name="description" expression="//*[local-name()='Description']" scope="operation"/>
													<property name="pictureURL" expression="//*[local-name()='PictureURL']" scope="operation"/>													
													<!-- Concatenate every item title and item URL to construct the Facebook message body to do a wall post for all promoted items. -->
													<property name="fbMessageBody" expression="fn:concat(get-property('operation','fbMessageBody'),' ',get-property('operation','title'),'-',get-property('operation','viewItemURL'),',')" scope="operation"/>
<!-- Create a json payload for campaign monitor for single item in ebay -->
													<payloadFactory media-type="json">
														<format>{
																	"item": {
																		"Layout": "$1",
																		"Singlelines": [
																				{
																					"Content": "$2",
																					"Href": "$3"
																				}
																		],
																		"Multilines": [
																				{
																					"Content": "$4"
																				}
																		],
																		"Images": [
																				{
																					"Content": "$5",
																					"Alt": "$6",
																					"Href": "$7"
																				}
																		]
																	}
																}
														</format>
														<args>
														  <arg expression="get-property('operation','title')" />
														  <arg expression="get-property('operation','title')" />
														  <arg expression="get-property('operation','viewItemURL')" />
														  <arg expression="get-property('operation','description')" />
														  <arg expression="get-property('operation','pictureURL')" />
														  <arg expression="get-property('operation','title')" />
														  <arg expression="get-property('operation','viewItemURL')" />
														</args>
													</payloadFactory>
<!-- Getting the current payload as a string. -->
													<property name="itemContent" expression="json-eval($.item)" scope="operation"/>
													<!-- Appending every item payload with a comma. -->
													<property name="itemsContent" expression="fn:concat(get-property('operation','itemsContent'),get-property('operation','itemContent'),',')" scope="operation" />
													
													<!-- Increment the item index by one. -->
													<property name="itemIndex" expression="get-property('operation','itemIndex') + 1" scope="operation"/>
												</sequence>
											</target>
										</iterate>										
										<!-- Restrict the execution of the rest of the API calls until the last item to the iterator performs getItem details and payload construction for all the eBay items. -->
										<filter xpath="get-property('operation','itemIndex') = get-property('itemCount')" >
											<then>
												<!-- Remove the last comma appended at the end of the last item payload. -->
												<property name="itemsContent" expression="fn:substring(get-property('operation', 'itemsContent'), 1, fn:string-length(get-property('operation','itemsContent'))-1)" scope="operation"/>												
												<!-- Create a payload with every appended repeater's items campaign creation for all promotional items. -->
												<payloadFactory media-type="json">
													<format>
														{
															"templateContent": {
																"Repeaters": [
																		{
																			"Items": [$1]
																		}
																]
															}
														}       
													</format>
													<args>
														<arg expression="get-property('operation','itemsContent')" />       
													</args>
												</payloadFactory>
												<!-- Get the whole template content into a property from the payload. -->
												<property name="cmTemplateContent" expression="json-eval($.templateContent)"/>
												<!-- Remove the last comma appended at the end of the last Facebook message body. -->
												<property name="fbMessageBody" expression="fn:substring(get-property('operation', 'fbMessageBody'),0,fn:string-length(get-property('operation','fbMessageBody')))" />												
												<!-- If Campaign Monitor access token is not available, give the custom error message; otherwise, proceed with the Campaign Monitor call. -->
												<filter source="boolean(get-property('cmAccessToken'))" regex="false">
													<then>           
														<property name="status" value="Skipped" />
														<property name="message" value="Please provide the Campaign Monitor authentication token." />
													</then>
													<else>
<!-- Call the cm-createCampaignFromTemplate of both Campaign Monitor and Facebook to create a campaign and wall post for eBay promotional sale items.-->
														<call-template target="ebay-publishItemDetailsOnSocialMedia">
															<!-- The parameter values will be passed on to a sequence template. -->
															(
															<with-param name="cmApiUrl" value="{$ctx:cmApiUrl}"/> |
															<with-param name="cmAccessToken" value="{$ctx:cmAccessToken}"/> |
															<with-param name="cmClientId" value="{$ctx:cmClientId}"/> |
															<with-param name="cmName" value="{$ctx:cmName}"/> |
															<with-param name="cmSubject" value="{$ctx:cmSubject}"/> |
															<with-param name="cmFromName" value="{$ctx:cmFromName}"/> |
															<with-param name="cmFromEmail" value="{$ctx:cmFromEmail}"/> |
															<with-param name="cmReplyTo" value="{$ctx:cmReplyTo}"/> |
															<with-param name="cmListIds" value="{$ctx:cmListIds}"/> |
															<with-param name="cmSegmentIds" value="{$ctx:cmSegmentIds}"/> |
															<with-param name="cmTemplateId" value="{$ctx:cmTemplateId}"/> |
															<with-param name="cmTemplateContent" value="{$ctx:cmTemplateContent}"/> |
															) *
														</call-template>
													</else>
												</filter>
<!-- Calling the response handler template to give the detailed message of campaign creation with promotional sale details. -->
												<call-template target="responseHandlerTemplate">
													<with-param name="activity" value="campaignMonitor_createCampaign" />
													<with-param name="id" value="{$ctx:idParam}" />
													<with-param name="status" value="{$ctx:status}" />
													<with-param name="message" value="{$ctx:message}" />
												</call-template>												
												<!-- If Facebook access token is not available, give custom error message; otherwise, proceed with the Facebook wall post creation call. -->
												<filter source="boolean(get-property('fbAccessToken'))" regex="false">
													<then>           
														<property name="status" value="Skipped" />
														<property name="message" value="Please provide the Facebook authentication token." />
													</then>
													<else>
														<property name="cmAccessToken" value="" />
														<!-- Call the cm-createCampaignFromTemplate of both Campaign Monitor and Facebook to create a campaign and wall post for eBay promotional sale items. -->
														<call-template target="ebay-publishItemDetailsOnSocialMedia">
															<!-- Parameter values will be passed on to a sequence template. -->
															(
															<with-param name="cmAccessToken" value="{$ctx:cmAccessToken}"/> |
															<with-param name="fbApiUrl" value="{$ctx:fbApiUrl}"/> |
															<with-param name="fbAccessToken" value="{$ctx:fbAccessToken}"/> |
															<with-param name="fbConnection" value="{$ctx:fbConnection}"/> |
															<with-param name="fbMessageBody" value="{$ctx:fbMessageBody}"/> |
															<with-param name="fbLink" value="{$ctx:fbLink}"/> |
															<with-param name="fbPicture" value="{$ctx:fbPicture}"/> |
															<with-param name="fbName" value="{$ctx:fbName}"/> |
															<with-param name="fbCaption" value="{$ctx:fbCaption}"/> |
															<with-param name="fbDescription" value="{$ctx:fbDescription}"/> |
															<with-param name="fbActions" value="{$ctx:fbActions}"/> |
															<with-param name="fbPlace" value="{$ctx:fbPlace}"/> |
															<with-param name="fbTags" value="{$ctx:fbTags}"/> |
															<with-param name="fbPrivacy" value="{$ctx:fbPrivacy}"/> |
															<with-param name="fbObjectAttachment" value="{$ctx:fbObjectAttachment}"/> |
															) *
														</call-template>
													</else>
												</filter>
<!-- Calling the response handler template to give the detailed message of posting promotional sale details of eBay on the seller's wall in Facebook. -->
												<call-template target="responseHandlerTemplate">
													<with-param name="activity" value="facebook_createWallPost" />
													<with-param name="id" value="{$ctx:idParam}" />
													<with-param name="status" value="{$ctx:status}" />
													<with-param name="message" value="{$ctx:message}" />
												</call-template>												
												<loopback/>
											</then>
										</filter>
									</else>
								</filter>
							</else>
						</filter>
					</else>
				</filter>
			</else>
		</filter>
	  </inSequence>
      <outSequence>
<property name="messageType" value="application/json" scope="axis2"/>
			<payloadFactory media-type="json">
				<format>
					{
						"Response":{
							"process":"ebay_retrieveAndPublishPromotionalDetails",
							"activityResponse":[$1]
						}
					}
				</format>
				<args>
					<arg evaluator="xml" expression="get-property('operation', 'responseString')"/>
				</args>
			</payloadFactory>
        <send/>
      </outSequence>
    </target>
    <description/>
</proxy>
Sample Request for Converting eBay Item(s) for Promotional Sale
{
	"ebayApiUrl":"https://api.sandbox.ebay.com/wsapi",
	"ebayAppId":"Virtusa37-a57a-43a3-8f97-fa1e9e2f195",
	"ebayVersion":"883",
	"ebayRouting":"default",
	"ebaySiteId":"203",
	"ebayAuthToken":"AgAAAA**AQAAAA**aAAAAA**lXzgUw**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wFk4GhDJWLowmdj6x9nY+seQ**VPkCAA**AAMAAA**x9umxS4e6RYDx2DT56ufBcZ+QI+deNI4+Eb78MmDsW57egJgGVTx7vUXRygKTlIQOmNbMyh4cNSwAYFz2q896JZ5f5xxjInZiJqPk+rlmgvN3rqgKYDSS4t0tjmD/UrcPXGYeqNViZIvyYWq0SW67wsvNQTI0IAr3h6So3QcTOR9NPr+lKgQixYzWPrP2Xuy+XkuGraWP5zcNOF0hrKu9iUmSYO8/DgfhGXsfBsamGDTh3vRlltEcDzKNV4RznNudC/eBt4cmB271EppOT16N7NaYXoQ0zwiBZHOrsYvOm3ae36Rjbdo/k94Nd61gBSbnt3U2QFn6I9D2pZ1FFATMXiCiPoXPL2v20f+ZzZX0cTostBZmYDJn1XwiXAnFH+km7Emb91atesP1F22nmzKbP4hIJch86Ll515/wsoVPf7AMxwtUn0s75jeqX/LGpQUSXLL0JPQZPWpanz1q58r+7NwQza9fGHPHzia3kfVd+11UnTomxK1U66IVPmVeyyVe7z9vYTqvD+PzKVCWFqLMooa/Q1KjwbHcFsOnBTGLnoLTqK21t6GQsmkbPnYrNiWpfzd+NGWG/3WajNn7nTtvOS1MBFBaJm2sw6SqAxuINSPv1Rr/8o4W7YWJdN6YiB7VbY/Xml6dO+GF47ePQm1x4su5DrrgpVc9H3FwqpJEE+XJ2qlY2OfrguxGbQK/Xqr85ExXujxxDb/YIbOnHCKi+DNfjO9Z4Nbv6QZHsXbopl9UbPqj0zHhbdvM8dUh8BJ",
	"ebayAction":"Add",
	"ebayPromotionalSaleName":"Promotional Demo Name",
	"ebayPromotionalSaleStartTime":"2014-10-28T19:09:02",
	"ebayPromotionalSaleEndTime":"2014-10-29T19:09:02",
	"ebayPromotionalSaleType":"FreeShippingOnly",
	"ebayPromotionalSaleItemIDArray":[
								"110152609553",
								"110152609595",
								"110152609631"
							   ],
	"ebayDetailLevel":"ReturnAll",
	"cmApiUrl":"https://api.createsend.com",
	"cmAccessToken":"AalKk9NhenpLj4IRXu3+IGAyNg==",
	"cmTemplateId":"afa130dd1c9e9fb0deb4626091910eb9",
	"cmReplyTo":"demoemail@mydomain.com",
	"cmSubject":"Campaign Demo Subject",
	"cmName":"Campaign Demo Name22",
	"cmFromEmail":"demoemail@mydomain.com",
	"cmListIds":[
					"b3034075faf920bd06ca5d3987cf5604"
    			  ],
    "cmFromName":"Demo From Name",
    "cmClientId":"76b9f6a6c87042c0cd443f1698502824",
    "fbApiUrl":"https://graph.facebook.com",
    "fbAccessToken":"CAACEdEose0cBAH8eoqewiSaoIFpoTlJkGUBAKxsAZB1nzsqNFAugZAXJSiLmtFyGMblxcz0mgWxIcS35OLoaM7w1gdYvewMBf8sZCZBjJd2l81Fo8tRFqo6S0K17D03cohXD0aZCxbnYfur3ziKFZCc8BGGr9nT3Vm34cWs2HCUYzj4ZCfepPAtUh798bXls3FB5wRtNsoyyHcmVIumbsrt"
}
Sample Template for Creating eBay Classified Ads According to the Given Parameters
<?xml version="1.0" ?>
<!-- This template creates eBay Classified Ads according to the given parameters. -->
<template name="ebay-addClassifiedAdToeBay" xmlns="http://ws.apache.org/ns/synapse">
    <parameter name="apiUrl" description="The URL of the eBay SOAP API."/>
	<parameter name="appId" description="The eBay application ID."/>
	<parameter name="version" description="The eBay request version."/>
	<parameter name="routing" description="The eBay routing."/>
	<parameter name="siteId" description="The site id of eBay."/>
	<parameter name="authToken" description="The eBay authentication token."/>
	<parameter name="messageId" description="The ID of the message."/>
	<parameter name="errorLanguage" description="The error language of the response."/>
	<parameter name="warningLevel" description="The warning level of the response."/>
	<parameter name="title" description="The title of the item."/>
	<parameter name="description" description="The description of the item."/>
	<parameter name="categoryID" description="Category ID of the category the item belongs to."/>
	<parameter name="startPrice" description="The starting price of the item."/>
	<parameter name="conditionId" description="Condition ID for the item."/>
	<parameter name="country" description="The country for the sale."/>
	<parameter name="location" description="The location of the sale."/>
	<parameter name="currency" description="The currency to sell in."/>
	<parameter name="listingDuration" description="The listing duration of the item."/>
	<parameter name="paymentMethods" description="Payment methods for the sale."/>
	<parameter name="paypalEmailAddress" description="The PayPal email address for the account."/>
	<parameter name="pictureUrl" description="The URL to a picture of the item."/>
	<parameter name="postalCode" description="The postal code of the seller."/>
	<parameter name="site" description="Site ID to post the item on."/>
	<parameter name="uuid" description="Unique ID for the item."/>
	<parameter name="itemSpecifics" description="Item specifications as the name value list." />
    <sequence>
    	<property name="uri.var.apiUrl" expression="$func:apiUrl"/>
	    <property name="uri.var.appId" expression="$func:appId"/>
	    <property name="uri.var.version" expression="$func:version"/>
	    <property name="uri.var.routing" expression="$func:routing"/>
	    <property name="uri.var.siteId" expression="$func:siteId"/>
	    <property name="uri.var.authToken" expression="$func:authToken"/>
	    <property name="uri.var.messageId" expression="$func:messageId"/>
	    <property name="uri.var.errorLanguage" expression="$func:errorLanguage"/>
	    <property name="uri.var.warningLevel" expression="$func:warningLevel"/>
	    <property name="uri.var.title" expression="$func:title"/>
	    <property name="uri.var.description" expression="$func:description"/>
	    <property name="uri.var.categoryID" expression="$func:categoryID"/>
	    <property name="uri.var.startPrice" expression="$func:startPrice"/>
	    <property name="uri.var.conditionId" expression="$func:conditionId"/>
	    <property name="uri.var.country" expression="$func:country"/>
	    <property name="uri.var.location" expression="$func:location"/>
	    <property name="uri.var.currency" expression="$func:currency"/>
	    <property name="uri.var.listingDuration" expression="$func:listingDuration"/>
	    <property name="uri.var.paymentMethods" expression="$func:paymentMethods"/>
	    <property name="uri.var.paypalEmailAddress" expression="$func:paypalEmailAddress"/>
	    <property name="uri.var.pictureUrl" expression="$func:pictureUrl"/>
	    <property name="uri.var.site" expression="$func:site"/>
	    <property name="uri.var.uuid" expression="$func:uuid"/>
		<property name="uri.var.itemSpecifics" expression="$func:itemSpecifics"/>
		<filter  source="boolean(get-property('uri.var.authToken'))" regex="false">
            <then>                            
				<property name="status" value="Skipped" />
				<property name="message" value="Please provide the eBay AUTH token." />						
            </then>
			<else>
				<!-- Set item payload. -->
				<payloadFactory media-type="xml">
					<format>
						<ebl:item xmlns:ebl="urn:ebay:apis:eBLBaseComponents">
							<ebl:values>
								<ebl:Title>$1</ebl:Title>
								<ebl:Description>$2</ebl:Description>
								<ebl:PrimaryCategory>
									<ebl:CategoryID>$3</ebl:CategoryID>
								</ebl:PrimaryCategory>
								<ebl:StartPrice>$4</ebl:StartPrice>
								<ebl:ConditionID>$5</ebl:ConditionID>
								<ebl:Country>$6</ebl:Country>
								<ebl:Location>$7</ebl:Location>
								<ebl:Currency>$8</ebl:Currency>
								<ebl:ListingDuration>$9</ebl:ListingDuration>
								<ebl:ListingType>LeadGeneration</ebl:ListingType>
								<ebl:ListingSubtype2>ClassifiedAd</ebl:ListingSubtype2>
								<ebl:PaymentMethods>$10</ebl:PaymentMethods>
								<ebl:PayPalEmailAddress>$11</ebl:PayPalEmailAddress>
								<ebl:PictureDetails>
									<ebl:PictureURL>$12</ebl:PictureURL>
								</ebl:PictureDetails>                        
								<ebl:PostalCode>$13</ebl:PostalCode>
								<ebl:Quantity>1</ebl:Quantity>
								<ebl:Site>$14</ebl:Site>
								<ebl:UUID>$15</ebl:UUID>
								<ebl:ItemSpecifics>$16</ebl:ItemSpecifics>
							</ebl:values>
						</ebl:item>
					</format>
					<args>
						<arg expression="get-property('uri.var.title')"/>
						<arg expression="get-property('uri.var.description')"/>
						<arg expression="get-property('uri.var.categoryID')"/>
						<arg expression="get-property('uri.var.startPrice')"/>
						<arg expression="get-property('uri.var.conditionId')"/>
						<arg expression="get-property('uri.var.country')"/>
						<arg expression="get-property('uri.var.location')"/>
						<arg expression="get-property('uri.var.currency')"/>
						<arg expression="get-property('uri.var.listingDuration')"/>
						<arg expression="get-property('uri.var.paymentMethods')"/>
						<arg expression="get-property('uri.var.paypalEmailAddress')"/>
						<arg expression="get-property('uri.var.pictureUrl')"/>
						<arg expression="get-property('uri.var.postalCode')"/>
						<arg expression="get-property('uri.var.site')"/>
						<arg expression="get-property('uri.var.uuid')"/>
						<arg expression="get-property('uri.var.itemSpecifics')" evaluator="xml"/>
					</args>
				</payloadFactory>
				<property name="uri.var.item" expression="//ebl:item/*"  xmlns:ebl="urn:ebay:apis:eBLBaseComponents"/>
				<ebay.init-trading>
					<apiUrl>{$ctx:uri.var.apiUrl}</apiUrl>
					<appId>{$ctx:uri.var.appId}</appId>
					<routing>{$ctx:uri.var.routing}</routing>
					<authToken>{$ctx:uri.var.authToken}</authToken>
					<siteId>{$ctx:uri.var.siteId}</siteId>
					<warningLevel>{$ctx:uri.var.warningLevel}</warningLevel>
					<messageId>{$ctx:uri.var.messageId}</messageId>
					<errorLanguage>{$ctx:uri.var.errorLanguage}</errorLanguage>
					<version>{$ctx:uri.var.version}</version>
				</ebay.init-trading>
				<ebay.addItem>
					<item>{$ctx:uri.var.item}</item>
					<detailLevel>{$ctx:uri.var.detailLevel}</detailLevel>
				</ebay.addItem>
				<property name="messageType" value="application/json" scope="axis2"/>
				<property name="ebayItemId" expression="json-eval($.Envelope.Body.AddItemResponse.ItemID)" />							
				<filter  source="boolean(get-property('ebayItemId'))" regex="false">
					<then>				
						<property name="status" value="Error" />
						<property name="message" expression="json-eval($.Envelope.Body.)" />						
					</then>
					<else>									
						<property name="status" value="Success" />
						<property name="message" expression="fn:concat('Classified Ad created successfully in eBay with the Classified Ad ID ',get-property('ebayItemId'),'.')" />
					</else>
				</filter>
			</else>
		</filter>
    </sequence>
</template>
Sample Proxy for Creating eBay Classified Ad Listings
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="ebay_retrieveAndCreateClassifiedAd"
       transports="https http"
       startOnLoad="true"
       trace="disable">
   <target>
      <inSequence onError="faultHandlerSeq">
         <property name="tradegeckoApiUrl" expression="json-eval($.tradegeckoApiUrl)"/>
         <property name="tradegeckoAccessToken" expression="json-eval($.tradegeckoAccessToken)"/>
         <property name="ebayApiUrl" expression="json-eval($.ebayApiUrl)"/>
         <property name="ebayAppId" expression="json-eval($.ebayAppId)"/>
         <property name="ebayVersion" expression="json-eval($.ebayVersion)"/>
         <property name="ebayRouting" expression="json-eval($.ebayRouting)"/>
         <property name="ebaySiteId" expression="json-eval($.ebaySiteId)"/>
         <property name="ebayAuthToken" expression="json-eval($.ebayAuthToken)"/>
         <property name="ebayMessageId" expression="json-eval($.ebayMessageId)"/>
         <property name="ebayErrorLanguage" expression="json-eval($.ebayErrorLanguage)"/>
         <property name="ebayWarningLevel" expression="json-eval($.ebayWarningLevel)"/>
         <property name="productCount" expression="count(//items/data)" scope="operation"/>
         <property name="responseString" value="" scope="operation"/>
         <property name="productIndex" value="0" scope="operation"/>
         <iterate continueParent="true"
                  id="products"
                  expression="//items/data"
                  sequential="true">
            <target>
               <sequence>
                 <property name="variantId" expression="//data/tradegeckoVariantId/text()" />
                  <property name="ebayCategoryId" expression="//data/ebayProductDetails/categoryId/text()"/>
				 <property name="ebayConditionId" expression="//data/ebayProductDetails/conditionId/text()"/>
                  <property name="ebayCountry" expression="//data/ebayProductDetails/country/text()"/>
                  <property name="ebayLocation" expression="//data/ebayProductDetails/location/text()"/>
                  <property name="ebayCurrency" expression="//data/ebayProductDetails/currency/text()"/>
                  <property name="ebayPictureUrlBackup" expression="//data/ebayProductDetails/pictureUrl/text()"/>
                  <property name="ebayListingDuration" expression="//data/ebayProductDetails/listingDuration/text()"/>
                  <property name="ebayPaymentMethods" expression="//data/ebayProductDetails/paymentMethods/text()"/>
                  <property name="ebayPaypalEmailAddress" expression="//data/ebayProductDetails/paypalEmailAddress/text()"/>
                  <property name="ebayPostalCode" expression="//data/ebayProductDetails/postalCode/text()"/>
                  <property name="ebaySite" expression="//data/ebayProductDetails/site/text()"/>
                  <property name="ebayUuid" expression="//data/ebayProductDetails/uuid/text()"/>				  
                  <property name="id" expression="fn:concat('variant_id:',get-property('variantId'))" />				  
                 <filter  source="boolean(get-property('variantId'))" regex="false">
                    <then>                           
						<property name="status" value="Error" />
						<property name="message" value="Please provide TradeGecko Variant Id." />						
                    </then>
                    <else>				
                        <tradegecko.init>
							<apiUrl>{$ctx:tradegeckoApiUrl}</apiUrl>
							<accessToken>{$ctx:tradegeckoAccessToken}</accessToken>
						</tradegecko.init>
						<tradegecko.getProduct>
							<id>{$ctx:variantId}</id>
							<getProductBy>variantId</getProductBy>
						</tradegecko.getProduct>						
                        <!-- remove TradeGecko Response Headers -->
						<sequence key="tradegecko-removeResponseHeaders" />						
                        <property  name="variantDetails" expression="json-eval($.variant)"/>						
                       <!-- if variant details are not available at TreadGecko -->
						<filter  source="boolean(get-property('variantDetails'))" regex="false">
                           <then>
								<filter source="$axis2:HTTP_SC" regex="401">
										<then>
											<property name="status" value="Error" />
											<property name="message" value="Invalid access token."  />
										</then>
										<else>
											<property name="status" value="Error" />
											<property name="message" expression="json-eval($.)"  />
										</else>
								</filter>					
							</then>
							<else>							
								<property name="tradegeckoProductId" expression="json-eval($.variant.product_id)" />
								<property name="ebayTitle" expression="json-eval($.variant.name)" />
								<property name="ebayDescription" expression="json-eval($.variant.description)" />
								<property name="ebayStartPrice" expression="json-eval($.variant.retail_price)" />								
                              <script language="js">
									<![CDATA[     
										var jsonPayload=mc.getPayloadJSON();
										var optVal={};
										optVal['opt1'] = jsonPayload.variant.opt1;
										optVal['opt2'] = jsonPayload.variant.opt2;
										optVal['opt3'] = jsonPayload.variant.opt3;										
										mc.setProperty('optVal',optVal);											
									]]>
									</script>
									<tradegecko.init>
										<apiUrl>{$ctx:tradegeckoApiUrl}</apiUrl>
										<accessToken>{$ctx:tradegeckoAccessToken}</accessToken>
									</tradegecko.init>
									<tradegecko.getProduct>
										<id>{$ctx:tradegeckoProductId}</id>
										<getProductBy>productid</getProductBy>
									</tradegecko.getProduct>									
									<!-- remove TradeGecko Response Headers -->
									<sequence key="tradegecko-removeResponseHeaders" />									
									<script language="js">
									<![CDATA[     
										var jsonPayload=mc.getPayloadJSON();
										var optVal=mc.getProperty('optVal');
										var nameValueList = "";										
										var opt={};
										opt['opt1'] = jsonPayload.product.opt1;
										opt['opt2'] = jsonPayload.product.opt2;
										opt['opt3'] = jsonPayload.product.opt3;										
										for (var key in opt) {
											var optName=opt[key];
											var optValue=optVal[key];
											if(optName != null && optName !='' && optValue != null && optValue !=''){												
												nameValueList +="<ebl:NameValueList xmlns:ebl='urn:ebay:apis:eBLBaseComponents'><ebl:Name>"+optName+"</ebl:Name><ebl:Value>"+optValue+"</ebl:Value></ebl:NameValueList>";
											}
										}									
										mc.setProperty('itemSpecifics',nameValueList);								
											
									]]>
									</script>									
									<!-- remove TradeGecko Response Headers -->
									<sequence key="tradegecko-removeResponseHeaders" />									
									<property name="ebayPictureUrl" expression="json-eval($.product.image_url)" />									
									<filter xpath="get-property('ebayPictureUrl')!='null'">
										<then>
											<property name="ebayPictureUrl" expression="fn:concat('http://',fn:substring-after(get-property('ebayPictureUrl'),'https://'))" />
										</then>
									  <else>
										<property name="ebayPictureUrl" expression="get-property('ebayPictureUrlBackup')" />
									  </else>
									</filter>									
                              <call-template target="ebay-addClassifiedAdToeBay">
                                 <with-param name="apiUrl" value="{$ctx:ebayApiUrl}"/>
                                 <with-param name="appId" value="{$ctx:ebayAppId}"/>
                                 <with-param name="version" value="{$ctx:ebayVersion}"/>
                                 <with-param name="routing" value="{$ctx:ebayRouting}"/>
                                 <with-param name="siteId" value="{$ctx:ebaySiteId}"/>
                                 <with-param name="authToken" value="{$ctx:ebayAuthToken}"/>
                                 <with-param name="messageId" value="{$ctx:ebayMessageId}"/>
                                 <with-param name="errorLanguage" value="{$ctx:ebayErrorLanguage}"/>
                                 <with-param name="warningLevel" value="{$ctx:ebayWarningLevel}"/>
                                 <with-param name="title" value="{$ctx:ebayTitle}"/>
                                 <with-param name="description" value="{$ctx:ebayDescription}"/>
                                 <with-param name="categoryID" value="{$ctx:ebayCategoryId}"/>
                                 <with-param name="startPrice" value="{$ctx:ebayStartPrice}"/>
                                 <with-param name="conditionId" value="{$ctx:ebayConditionId}"/>
                                 <with-param name="country" value="{$ctx:ebayCountry}"/>
                                 <with-param name="location" value="{$ctx:ebayLocation}"/>
                                 <with-param name="currency" value="{$ctx:ebayCurrency}"/>
                                 <with-param name="listingDuration" value="{$ctx:ebayListingDuration}"/>
                                 <with-param name="paymentMethods" value="{$ctx:ebayPaymentMethods}"/>
                                 <with-param name="paypalEmailAddress" value="{$ctx:ebayPaypalEmailAddress}"/>
                                 <with-param name="pictureUrl" value="{$ctx:ebayPictureUrl}"/>
                                 <with-param name="postalCode" value="{$ctx:ebayPostalCode}"/>
                                 <with-param name="site" value="{$ctx:ebaySite}"/>
                                 <with-param name="uuid" value="{$ctx:ebayUuid}"/>
								 <with-param name="itemSpecifics" value="{$ctx:itemSpecifics}" />
                              </call-template>
                           </else>
                        </filter>
                     </else>
                  </filter>
                  <call-template target="responseHandlerTemplate">
                     <with-param name="id" value="{$ctx:id}"/>
                     <with-param name="status" value="{$ctx:status}"/>
                     <with-param name="message" value="{$ctx:message}"/>
                  </call-template>
                  <property name="productIndex"
                            expression="get-property('operation','productIndex') + 1"
                            scope="operation"/>
               </sequence>
            </target>
         </iterate>
         <filter xpath="get-property('operation','productCount') = get-property('operation','productIndex')">
            <then>
               <loopback/>
            </then>
         </filter>
      </inSequence>
      <outSequence>
         <property name="messageType" value="application/json" scope="axis2"/>
         <payloadFactory media-type="json">
            <format>
				{
				"Response":{
					"process":"ebay_retrieveAndCreateClassifiedAd",
					"activityResponse":[$1]
				}
				}
			</format>
            <args>
               <arg evaluator="xml"
                    expression="get-property('operation', 'responseString')"/>
            </args>
         </payloadFactory>
         <send/>
      </outSequence>
   </target>
</proxy>                                                
Sample Request for Creating eBay Classified Ad Listings
{
	"tradegeckoApiUrl" : "https://api.tradegecko.com",
	"tradegeckoAccessToken" : "d2c1804ba59a8aea6e8a7a5bf3bda6c8fbadc4a7b87b6e660651b8159ccf4498",
	"items" : { "data" :[
					{
						"tradegeckoVariantId"	: "3747757",
						"ebayProductDetails"	: {
									"categoryId" 				: "71484",
									
									"conditionId" 				: "1000",
									"country" 					: "US",
									"location"					: "San Jose,CA",
									"currency" 					: "USD",											
									"listingDuration" 			: "Days_30",
									"paymentMethods"			: "PayPal",
									"paypalEmailAddress"		: "wso2connector@gmail.com",									
									"pictureUrl"				: "http://i1.sandbox.ebayimg.com/03/i/00/6b/63/03_1.JPG?set_id=8800005007",
									"postalCode"				: "95125",
									"site"						: "US",
									"uuid"						: "c24fd1af6a7a47c8a243d897c7bf9ddd"
								}  		
					},
					{
						"tradegeckoVariantId"	: "3747759",
						"ebayProductDetails"	: {
									"categoryId" 				: "71484",
									
									"conditionId" 				: "1000",
									"country" 					: "US",
									"location"					: "San Jose,CA",
									"currency" 					: "USD",
									"listingDuration" 			: "Days_30",
									"paymentMethods"			: "PayPal",
									"paypalEmailAddress"		: "wso2connector@gmail.com",	
									"pictureUrl"				: "http://i1.sandbox.ebayimg.com/03/i/00/6b/63/03_1.JPG?set_id=8800005007",
									"postalCode"				: "95125",
									"site"						: "US",
									"uuid"						: "c25fd1ea6a7a47c8b983d798c8bf9ddd"
								}
						}
				]
		},
	"ebayApiUrl" : "https://api.sandbox.ebay.com/wsapi",
	"ebayAuthToken" : "AgAAAA**AQAAAA**aAAAAA**lXzgUw**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wFk4GhDJWLowmdj6x9nY+seQ**VPkCAA**AAMAAA**x9umxS4e6RYDx2DT56ufBcZ+QI+deNI4+Eb78MmDsW57egJgGVTx7vUXRygKTlIQOmNbMyh4cNSwAYFz2q896JZ5f5xxjInZiJqPk+rlmgvN3rqgKYDSS4t0tjmD/UrcPXGYeqNViZIvyYWq0SW67wsvNQTI0IAr3h6So3QcTOR9NPr+lKgQixYzWPrP2Xuy+XkuGraWP5zcNOF0hrKu9iUmSYO8/DgfhGXsfBsamGDTh3vRlltEcDzKNV4RznNudC/eBt4cmB271EppOT16N7NaYXoQ0zwiBZHOrsYvOm3ae36Rjbdo/k94Nd61gBSbnt3U2QFn6I9D2pZ1FFATMXiCiPoXPL2v20f+ZzZX0cTostBZmYDJn1XwiXAnFH+km7Emb91atesP1F22nmzKbP4hIJch86Ll515/wsoVPf7AMxwtUn0s75jeqX/LGpQUSXLL0JPQZPWpanz1q58r+7NwQza9fGHPHzia3kfVd+11UnTomxK1U66IVPmVeyyVe7z9vYTqvD+PzKVCWFqLMooa/Q1KjwbHcFsOnBTGLnoLTqK21t6GQsmkbPnYrNiWpfzd+NGWG/3WajNn7nTtvOS1MBFBaJm2sw6SqAxuINSPv1Rr/8o4W7YWJdN6YiB7VbY/Xml6dO+GF47ePQm1x4su5DrrgpVc9H3FwqpJEE+XJ2qlY2OfrguxGbQK/Xqr85ExXujxxDb/YIbOnHCKi+DNfjO9Z4Nbv6QZHsXbopl9UbPqj0zHhbdvM8dUh8BJ",
	"ebaySiteId" : "0",
	"ebayVersion" : "843", 
	"ebayAppId" : "Virtusa37-a57a-43a3-8f97-fa1e9e2f195",
	"ebayRouting" : "default",
	"ebayWarningLevel" : "",
	"ebayErrorLanguage" : "en_US"
					
}