转换php代码(Web服务调用)到asp.net c#(Web服务调用) [英] Convertion of php code(web service call) to asp.net c#(web service call)
问题描述
这是yogesh sharma,我是一名dotnet开发人员,我需要在我的项目中调用一个Web服务...但是我的Web服务提供商给了我用PHP编写的Web服务调用演示...而且我根本不懂PHP。所以请允许任何人通过向我提供php代码到asp.net c#代码的转换来帮助我。任何帮助将不胜感激...
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...
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'
结果
'; print_r($result); echo '
';
echo $ result-> GenerateWayBillResult-> AWBPrintContent;
类DebugSoapClient扩展SoapClient {
public $ sendRequest = true;
public $ printRequest = true;
public $ formatXML = true;
公共函数__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){
返回parent :: __ doRequest($ request,$ location, $ action,$ version,$ one_way);
}
else {
return'';
}
}
}
我尝试过:
i搜索了一些将php代码转换为asp.net代码的工具(迁移助手)。但有.net版本问题..
';
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..
推荐答案
soap = new DebugSoapClient('http://netconnect.bluedart.com/Ver1.2/Demo/ ShippingAPI / WayBill / WayBillGeneration.svc?wsdl',
数组(
'trace'=> 1,
'style'=> SOAP_DOCUMENT,
'use'=> ; SOAP_LITERAL,
'soap_version'=> SOAP_1_1
));
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->__setLocation("http://netconnect.bluedart.com/Ver1.2/Demo/ShippingAPI/Waybill/WayBillGeneration.svc/Basic");
soap-> sendRequest = true;
soap->sendRequest = true;
这篇关于转换php代码(Web服务调用)到asp.net c#(Web服务调用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!