Code:
Hi,

I have been working on a script that loops through multiple records and sends data (one record per call) to a WS.

I am supposed to make a new call for each record before sending the data.
The problem I have is the first record gets processed fine where as the second record always; reason being the EAI expects it to be a seperate call
Though I am creating/reseting a new service everytime within the foreach loop the data seems to be going as a single call.

If you see record 1 and 2 below it has 2 different namespace i.e. namesp1 and namesp2; The EAI is expection namesp1 for both.

Any suggestions on this would be greatly appreciated.

Please find the sample code below

Thanks,
Vignesh


<code>
Result:

----------Record 1--------------------

SOAP::Transport::HTTP::Client::send_receive: POST XXXX
Accept: text/xml
Accept: multipart/*
Content-Length: 4174
Content-Type: text/xml; charset=iso-8859-1
SOAPAction: "XXXX#MyService"

<?xml version="1.0" encoding="iso-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENC="XXXX" SOAP-ENV:encodingStyle="XXXX" xmlns:SOAP-ENV="XXXX" xmlns:xsi="XXXX" xmlns:xsd="XXXX">
<SOAP-ENV:Body><namesp1:MyService xmlns:namesp1="XXXX">
<eSparesMessage>
<Header>
<Basic>
<ServiceType xsi:type="xsd:string">Return for Repair</ServiceType>
<OrderType xsi:type="xsd:string">SO</OrderType>
<ServiceObjectiveType xsi:type="xsd:string">Deliver</ServiceObjectiveType>
</Header>
<LineItem>
<PartTrackingNumber xsi:type="xsd:string">5-0277051.001</PartTrackingNumber>
<ItemLineNumber xsi:type="xsd:int">1</ItemLineNumber>
</LineItem></eSparesMessage>
</namesp1:MyService></SOAP-ENV:Body></SOAP-ENV:Envelope>

SOAP::Transport::HTTP::Client::send_receive: HTTP/1.0 200 OK
Connection: Close
Content-Length: 551
Content-Type: text/xml;charset=utf-8
Client-Date: Mon, 18 May 2009 13:45:52 GMT
Client-Peer: 139.54.50.110:6055
Client-Response-Num: 1
Set-Cookie: ssnid=607wTxHRjth3kUcEx81g2G648Lg4bA-6055110; path=/;

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="XXXX" xmlns:SOAP-ENC="XXXX" xmlns:xsd="XXXX" xmlns:xsi="XXXX-instance">
<SOAP-ENV:Body>
<namesp1:ReturnCode xmlns:namesp1="XXXX">
  <Number>409</Number>
  <Message>Error on SPT 5-0277051.001 RMA already exist</Message>
</namesp1:ReturnCode></SOAP-ENV:Body>
</SOAP-ENV:Envelope>



-----------------Record 2-----------------------
SOAP::Transport::HTTP::Client::send_receive: POST XXXX
Accept: text/xml
Accept: multipart/*
Content-Length: 4851
Content-Type: text/xml; charset=iso-8859-1
SOAPAction: "XXXX#MyService"

<?xml version="1.0" encoding="iso-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENC="XXXX" SOAP-ENV:encodingStyle="XXXX" xmlns:SOAP-ENV="XXXX" xmlns:xsi="XXXX" xmlns:xsd="XXXX">
<SOAP-ENV:Body><namesp2:MyService xmlns:namesp2="XXXX">
<eSparesMessage>
<Header>
<Basic>
<ServiceType xsi:type="xsd:string">Return for Repair</ServiceType>
<OrderType xsi:type="xsd:string">SO</OrderType>
<ServiceObjectiveType xsi:type="xsd:string">Deliver</ServiceObjectiveType>
</Header>
<LineItem>
<PartTrackingNumber xsi:type="xsd:string">5-0277051.001</PartTrackingNumber>
<ItemLineNumber xsi:type="xsd:int">1</ItemLineNumber>
</LineItem></eSparesMessage>
</namesp1:MyService></SOAP-ENV:Body></SOAP-ENV:Envelope>

SOAP::Transport::HTTP::Client::send_receive: HTTP/1.0 200 OK
Connection: Close
Content-Length: 483
Content-Type: text/xml;charset=utf-8
Client-Date: Mon, 18 May 2009 13:46:03 GMT
Client-Peer: 139.54.50.110:6055
Client-Response-Num: 1
Set-Cookie: ssnid=608VHK+hloKXk7KOxJLtI5+9F|Jh0U-6055110; path=/;

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="XXXX" xmlns:SOAP-ENC="XXXX" xmlns:xsd="XXXX" xmlns:xsi="XXXX-instance">
<SOAP-ENV:Body>
<namesp1:ReturnCode xmlns:namesp1="XXXX">
  <Number>2</Number>
</namesp1:ReturnCode></SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Script:
foreach $rank_temp (@temp_arr){

		......Queries for rank to get corresponding records......
			
		......Loop for each record......
		foreach  (keys %eSpares_entries){
			
			$service = SOAP::Lite->uri($wsdl_path)
				 		 ->proxy($proxy_path)
						 ->encoding('iso-8859-1');

				
			......Get required data to be sent through EAI......
					
						
			 foreach $prd_id (keys %prd_entries){
			 
				$lineitem++;
				$lineitem_data = SOAP::Data->name('LineItem'			=> \SOAP::Data->value(SOAP::Data
									   ->name('PartTrackingNumber'  => $prd_entries{$prdid}->{$prd_field_values{'Supplier Service Order'}}), SOAP::Data
									   ->name('ItemLineNumber'		=> $lineitem), SOAP::Data
									   ->name('MaterialCode'		=> '3AL01001PP'), SOAP::Data
									   ->name('SwapAllowed'			=> $swap_allowed), SOAP::Data
									   ->name('ScrapAllowed'		=> $scrap_allowed), SOAP::Data
									   ->name('ReturnWarrantyFlag'	=> $prd_entries{$prdid}->{$prd_field_values{'Return Warranty Flag'}}), SOAP::Data
									   ->name('WBSNumber'			=> $sae_entries{$sae_id}->{$wbs_field_name}), SOAP::Data
									   ->name('InventoryAccount'	=> $prd_entries{$prdid}->{$prd_field_values{'Inventory Account'}}), SOAP::Data
									   ->name('ProblemSummary'		=> $prd_entries{$prdid}->{$prd_field_values{'Problem Description'}}), SOAP::Data
									   ->name('SWRelease'			=> $prd_entries{$prdid}->{$prd_field_values{'Additional Info'}})));
		 
				push (@lineitem_arr, $lineitem_data);
			}

				
				 $header_data =	SOAP::Data->name('eSparesMessage'				=> \SOAP::Data->value(SOAP::Data 
										  ->name('Header'						=> \SOAP::Data->value(SOAP::Data
										  ->name('Basic'						=> \SOAP::Data->value(SOAP::Data
										  ->name('ServiceType'					=> $supp_serv_ord_type), SOAP::Data
										  ->name('DirectShipmentIndicator'		=> 'Y'), SOAP::Data
										  ->name('OperationalFlowIndicator'     => 'C'), SOAP::Data
										  ->name('CustomerRequestedDate'		=> $cust_req_date), SOAP::Data
										  ->name('IncotermsType'				=> 'DDP'), SOAP::Data
										  ->name('IncotermsCity'				=> $inc_city), SOAP::Data
										  ->name('PaymentTerm'					=> $pay_term), SOAP::Data
										  ->name('B2BAgreementNumber'			=> $b2b_agreement), SOAP::Data
										  ->name('ServiceSLA'					=> $service_sla), SOAP::Data
										  ->name('ReplenishmentFlag'			=> $rep_flag), SOAP::Data
										  ->name('RMANumber'					=> $rma_number), SOAP::Data
										  ->name('CustomerReference'			=> $customer_reference), SOAP::Data
										  ->name('DeliveryTimeLine'				=> $delivery_time_line),SOAP::Data
										  ->name('DirectShipmentIndicator' => 'Y'))
											), SOAP::Data
										  ->name('lines'						=> @lineitem_arr)))); 

			..... Send data to EAI......
			$result = $service[$y]->MyService($header_data);

			}
			</code>