帮助将此 PHP 代码转换为 VB.NET 代码
我有一个通过 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);
I have a code to send XML via POST. But this code is in PHP and I need it in VB.NET.
Any help to convert this code?
$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";
And how I convert this PHP code too:
$msg=htmlentities($msg);
$msg=urlencode($msg);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用 HttpWebRequest 和 HttpWebResponse 类。代码可能看起来像这样(我的 VB 这些天有点生疏了):
You need to use the HttpWebRequest and HttpWebResponse classes. The code could would look something like this (my VB is a bit rusty these days):
请参阅:htmlentities 解决方案 和 urlencode解决方案
至于curl,看起来你正在尝试调用一项网络服务。如果它是一个正确的 Web 服务(意味着某处有 WSDL 和 XSD),您应该向您的项目添加一个服务引用(如果您使用的是 VS2005 或 VS2003,则添加一个 Web 引用),这将为您生成一个代理使用(而不是手动将 XML 转储到服务器)。
See: htmlentities solution and urlencode solution
And as far as curl, it looks like you're trying to call a web service. If it's a proper web service (meaning there is a WSDL and an XSD somewhere), you should add a Service Reference (or a Web Reference if you're in VS2005 or VS2003) to your project, which will generate a proxy for you to use (instead of manually dumping XML to a server).