使用Web服务:C#到php


Consuming a Webservice : C# to php

所以我一直在一个Web服务上运行一些测试,它在C#中运行得很好:

    // The objet to do the request
            server.CustomerWS Auth = new server.CustomerWS();
    // The object we will use to store the request
            server.customerXML Cust = new server.customerXML();
            // Request
            Cust = Auth.authenticate(login, password);

            if (cust.retour == true)
            {
                MessageBox.Show("OK");
            }
            else
            {
                MessageBox.Show("KO");
            }

我需要将这些代码转换为PHP,作为这门语言的新手,我会尽我所能帮助我入门,主要问题是我不知道如何用PHP处理来自Web服务的对象。

我没有在服务器上使用php5,所以我不能使用soap-php函数。

感谢您的帮助

// -- specify your Web Service URL and also the login and password (should be really protected : use HTTPS and send these parameters in POST)    
$url = 'http://....';
// The objet to do the request
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
// The object we will use to store the request
$result = NULL;
$xml = new SimpleXmlElement(curl_exec($curl)); 
if ($xml->retour[0] == true){ 
    print ("OK");
}else{
    print("KO");
}

希望能有所帮助:)