Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
帮助将此PHP代码转换为VB.NET代码_Php_Xml_Vb.net_Post_Encode - Fatal编程技术网

帮助将此PHP代码转换为VB.NET代码

帮助将此PHP代码转换为VB.NET代码,php,xml,vb.net,post,encode,Php,Xml,Vb.net,Post,Encode,我有一个通过POST发送XML的代码。但是这段代码是用PHP编写的,我需要用VB.NET编写 转换此代码有什么帮助吗 $XMLFile= (here i have created the xml file. XML is encoded ISO-8859) $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"URL WHERE I SEND XML"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt(

我有一个通过POST发送XML的代码。但是这段代码是用PHP编写的,我需要用VB.NET编写

转换此代码有什么帮助吗

$XMLFile= (here i have created the xml file. XML is encoded ISO-8859)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"URL WHERE I SEND XML");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POSTFIELDS,"XMLDATA=".$XMLFile);
$results=curl_exec ($ch);
curl_close ($ch);

$results=stripslashes($results);

$xmlreturned=new SimpleXMLElement($results);

if($xmlreturned->NotificationResultHeader->RRC==0){
if($xmlreturned->NotificationResultList->NotificationResult->NRC==0){
echo "OK. SUCCES"; 
以及如何转换此PHP代码:

$msg=htmlentities($msg);
$msg=urlencode($msg); 
见:和

至于curl,看起来您正在尝试调用一个web服务。如果它是一个合适的web服务(意味着某个地方有WSDL和XSD),您应该向项目中添加一个服务引用(如果您在VS2005或VS2003中,则添加一个web引用),这将生成一个代理供您使用(而不是手动将XML转储到服务器)。

您需要使用和类。代码可能是这样的(我的VB最近有些生疏):

Dim xmlDoc as XmlDocumnet
'
'  prepare you xml doc here...
'
Dim encoding as ASCIIEncoding = New ASCIIEncoding()
Dim postData as String 
postData = "XMLDATA=" + xmlDoc.ToString()
Dim data() as Byte 
data = encoding.GetBytes(postData)

' Prepare web request...
Dim myRequest as HttpWebRequest 
    myRequest = CType(WebRequest.Create("URL TO POST HERE"), HttpWebRequest)
myRequest.Method = "POST"
myRequest.ContentType="application/x-www-form-urlencoded"
myRequest.ContentLength = data.Length
Dim newStream as Stream  = myRequest.GetRequestStream()
' Send the data.
newStream.Write(data, 0, data.Length)

' Get the response
Dim myResponse as HttpWebResponse
myResponse = myRequest.GetResponse()