使用Web服务:C#到php

时间:2014-11-07 13:19:08

标签: c# php web-services

所以我已经在网络服务上运行了一些测试,而且我的代码在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功能。

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

// -- 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");
}

希望有所帮助:)