Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi this is yogesh sharma and i am a dotnet developer and i need to call a web service in my project... But my web service provider has given me web service calling demo which is written in PHP... And i don't know PHP at all. So please can anyone help me for the same by providing me with the conversion of the php code into asp.net c# code.? Any help will be appreciated...
PHP
header('Content-type: application/pdf');
	/* 
	#echo "Start  of Soap 1.1 version ( BasicHttpBinding) setting"
			$soap = new DebugSoapClient('http://netconnect.bluedart.com/Ver1.2/Demo/ShippingAPI/WayBill/WayBillGeneration.svc?wsdl',
			array(
			'trace' 							=> 1,  
			'style'								=> SOAP_DOCUMENT,
			'use'									=> SOAP_LITERAL,
			'soap_version' 				=> SOAP_1_1
			));
			
			$soap->__setLocation("http://netconnect.bluedart.com/Ver1.2/Demo/ShippingAPI/Waybill/WayBillGeneration.svc/Basic");
			
			$soap->sendRequest = true;
			$soap->printRequest = false;
			$soap->formatXML = true; 	
	#echo "end of Soap 1.1 version setting" 
	*/
	 
	 #echo "Start  of Soap 1.2 version (ws_http_Binding)  setting";
				$soap = new DebugSoapClient('http://netconnect.bluedart.com/Ver1.2/Demo/ShippingAPI/WayBill/WayBillGeneration.svc?wsdl',
				array(
				'trace' 							=> 1,  
				'style'								=> SOAP_DOCUMENT,
				'use'									=> SOAP_LITERAL,
				'soap_version' 				=> SOAP_1_2
				));
				
				$soap->__setLocation("http://netconnect.bluedart.com/Ver1.2/Demo/ShippingAPI/WayBill/WayBillGeneration.svc");
				
				$soap->sendRequest = true;
				$soap->printRequest = false;
				$soap->formatXML = true; 
				
				$actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing','Action','http://tempuri.org/IWayBillGeneration/GenerateWayBill',true);
				$soap->__setSoapHeaders($actionHeader);	
		#echo "end of Soap 1.2 version (WSHttpBinding)  setting";


$params = array(
'Request' => 
	array (
		'Consignee' =>
			array (
				'ConsigneeAddress1' => 'A',
				'ConsigneeAddress2' => 'A',
				'ConsigneeAddress3'=> 'A',
				'ConsigneeAttention'=> 'A',
				'ConsigneeMobile'=> '1234567890',
				'ConsigneeName'=> 'A',
				'ConsigneePincode'=> '462023',
				'ConsigneeTelephone'=> '1234567890',
			)	,
		'Services' => 
			array (
				'ActualWeight' => '1',
				'CollectableAmount' => '500',
				'Commodity' =>
					array (
						'CommodityDetail1'  => '1',
						'CommodityDetail2' => '1',
						'CommodityDetail3' => '1'
				),
				'CreditReferenceNo' => '6',
				'DeclaredValue' => '1000',
				'Dimensions' =>
					array (
						'Dimension' =>
							array (
								'Breadth' => '1',
								'Height' => '1',
								'Length' => '1'
							),
					),
					'InvoiceNo' => '',
					'PackType' => '',
					'PickupDate' => '2014-07-28',
					'PickupTime' => '1800',
					'PieceCount' => '1',
					'ProductCode' => 'A',
					'ProductType' => 'Dutiables',
					'SpecialInstruction' => '1',
					'SubProductCode' => 'C'
			),
			'Shipper' =>
				array(
		    'OriginArea' => 'AHD',
                    'CustomerCode' => '200233',
                    'CustomerAddress1' => 'A-404',
                    'CustomerAddress2' => 'smita tower, vishram nagar',
                    'CustomerAddress3' => 'gurukul',
                    'CustomerEmailID' => 'info@steamlite.com',
                    'CustomerMobile' => '09227404554',
                    'CustomerName' => 'SteamLite Sales Pvt Ltd',
                    'CustomerPincode' => '380052',
                    'CustomerTelephone' => '07940304554',
                    'IsToPayCustomer' => 'false', 
                    'VendorCode' => ' '   
				)
	),
	'Profile' => 
		 array(
			'Awbfilelocation' => '/steamlite.org/html/steam_customer/',    
		 	'Api_type' => 'S',
			'LicenceKey'=>'<license key>',
			'LoginID'=>'<INTERNETDART ID>',
			'Version'=>'1.3')
			);

// Here I call my external function
$result = $soap->__soapCall('GenerateWayBill',array($params));
 
#echo "Generated Waybill number " + $result->GenerateWayBillResult->AWBNo;
#echo $result->GenerateWayBillResult->Status->WayBillGenerationStatus->StatusInformation 

//echo "<br>";
//echo '<h2>Parameters</h2><pre>'; print_r($params); echo '
';
//echo "
";
//echo '

Result

'; print_r($result); echo '
';

echo $result->GenerateWayBillResult->AWBPrintContent;

class DebugSoapClient extends SoapClient {
public $sendRequest = true;
public $printRequest = true;
public $formatXML = true;

public function __doRequest($request, $location, $action, $version, $one_way=0) {
if ( $this->printRequest ) {
if ( !$this->formatXML ) {
$out = $request;
}
else {
$doc = new DOMDocument;
$doc->preserveWhiteSpace = false;
$doc->loadxml($request);
$doc->formatOutput = true;
$out = $doc->savexml();
}
echo $out;
}

if ( $this->sendRequest ) {
return parent::__doRequest($request, $location, $action, $version, $one_way);
}
else {
return '';
}
}
}



What I have tried:

i searched for some tool (migration assistant ) that convert php code to asp.net code. but there .net version problem..
Posted
Comments
Nathan Minier 12-Feb-16 7:35am    
Just get the wsdl.

Or to make life super easy, in Visual studio right-click on references, select "Add Service Reference", and put in the service address and you can automatically generate data access objects for that service.
Sinisa Hajnal 12-Feb-16 10:01am    
You don't have to rewrite the service, add the reference, create proxy object based on that and you're done

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900