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 http://bcv50s6e.vz.cit.alcatel.fr:6055/soap/WSSparePartProcessforeSpare
Accept: text/xml
Accept: multipart/*
Content-Length: 4174
Content-Type: text/xml; charset=iso-8859-1
SOAPAction: "http://bcv50s6e.vz.cit.alcatel.fr:6055/soap/WSSparePartProcessforeSpare#MyService"

<?xml version="1.0" encoding="iso-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body><namesp1:MyService xmlns:namesp1="http://bcv50s6e.vz.cit.alcatel.fr:6055/soap/WSSparePartProcessforeSpare">
<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="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<namesp1:ReturnCode xmlns:namesp1="http://www.alcatel-lucent.com/webservices/asi/WSSparePartProcessforeSpare">
  <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 http://bcv50s6e.vz.cit.alcatel.fr:6055/soap/WSSparePartProcessforeSpare
Accept: text/xml
Accept: multipart/*
Content-Length: 4851
Content-Type: text/xml; charset=iso-8859-1
SOAPAction: "http://bcv50s6e.vz.cit.alcatel.fr:6055/soap/WSSparePartProcessforeSpare#MyService"

<?xml version="1.0" encoding="iso-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body><namesp2:MyService xmlns:namesp2="http://bcv50s6e.vz.cit.alcatel.fr:6055/soap/WSSparePartProcessforeSpare">
<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="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<namesp1:ReturnCode xmlns:namesp1="http://www.alcatel-lucent.com/webservices/asi/WSSparePartProcessforeSpare">
  <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>

Try perlmonks.com if you get no replies here. I can't help with your question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.