PHP Bad Request在Curl上的SOAP接口http://www.cyberlogic.gr/webservices/PlaceSearch [英] PHP Bad Request in Curl on SOAP interface of http://www.cyberlogic.gr/webservices/PlaceSearch

查看:228
本文介绍了PHP Bad Request在Curl上的SOAP接口http://www.cyberlogic.gr/webservices/PlaceSearch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在PHP中使用curl调用url。我得到一个BAD REQUEST错误。
如果有人可以帮助我,我不会得到什么问题

I am trying to call the url using curl in php. I get a BAD REQUEST error . if someone can help me,I do not get what the problem is

他们的食谱如下: http://wl.filos.com.gr/services/WebService.asmx?op=PlaceSearch (看肥皂1.1)

Their "recipe" is as follows: http://wl.filos.com.gr/services/WebService.asmx?op=PlaceSearch (look at soap 1.1)

我的代码是:

  <?      
        // xml data    
        $soap_request  = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
              $soap_request .= "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n";
              $soap_request .= " <soap:Body>\n";
              $soap_request .= "  <PlaceSearch xmlns=\"http://www.cyberlogic.gr/webservices/\">\n";
              $soap_request .= "  <xml><PlaceSearchRequest><Username>SERUNCD</Username><Password>TA78UNC</Password><PlaceType>Cities</PlaceType><Language>en</Language></PlaceSearchRequest></xml>\n";
              $soap_request .= "   </PlaceSearch>\n";
              $soap_request .= "  </soap:Body>\n";
              $soap_request .= "</soap:Envelope>";

          // heder    
               $header = array(
    "POST /services/WebService.asmx HTTP/1.1",
    "Host: wl.filos.com.gr",
    "Content-type: text/xml; charset=utf-8",
    "Content-length: ".strlen($soap_request),
    "SOAPAction: \"http://www.cyberlogic.gr/webservices/PlaceSearch\""
  );


        // call currl  
            $soap_do = curl_init();
                      curl_setopt($soap_do, CURLOPT_URL, "http://wl.filos.com.gr/services/WebService.asmx?op=PlaceSearch" );
                      curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
                      curl_setopt($soap_do, CURLOPT_TIMEOUT,        10);
                      curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
                      curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
                      curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
                      curl_setopt($soap_do, CURLOPT_POST,           true );
                      curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $soap_request);
                      curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $header);
                      curl_getinfo($soap_do, CURLINFO_EFFECTIVE_URL);
                    curl_setopt($soap_do, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');

                     $output = curl_exec($soap_do);
                         $info = curl_getinfo($soap_do);
                           print_r(curl_getinfo($soap_do)) ;
                      if(curl_exec($soap_do) === false) {
                        $err = 'Curl error: ' . curl_error($soap_do);
                        curl_close($soap_do);
                        print $err;
                      } else {
                        curl_close($soap_do);
                        print 'Operation completed without any errors  <br />';
                      }


                            echo "The server responded: <br />";
                            echo   " " .  $info['http_code'];
    ?>


推荐答案

由于您没有SOAP的WSDL接口的www.cyberlogic.gr webservice,你将不会从与其他方法相比使用它,例如GET方法:

As you don't have a WSDL for the SOAP interface of the www.cyberlogic.gr webservice, you won't benefit from using it compared with the other methods, e.g. the GET method:

<?php
/**
 *  Example for cyberlogic.gr GET webservice
 */

// create the request XML
$request            = new SimpleXMLElement("<PlaceSearchRequest/>");
$request->Username  = "SERUNCD";
$request->Password  = "TA78UNC";
$request->PlaceType = "Cities";
$request->Language  = "en";

$url    = "http://wl.filos.com.gr/services/WebService.asmx/PlaceSearch";
$result = simplexml_load_file($url . "?xml=" . urlencode($request->asXML()));
if ($result) {
    // process result
    $count = 0;
    foreach ($result->Response->Cities->City as $City) {
        printf("#%03d: %s (%s)\n", $count++, $City->CityName, $City["city_id"]);
    }
}



此示例还显示如何访问city-id属性,这是使用PHP的 SoapClient 的标准结果解析和映射不容易实现的。由于结果类型仍然未定义,因此在 SoapClient 中执行此操作是不值得的。

This example also shows how to access the city-id attribute which was something not easily possible with standard result parsing and mapping of PHP's SoapClient. As the result type remains undefined anyway, doing this in SoapClient isn't worth the steps it would need to take.

示例输出: / p>

Example Output:

#000: Achladies (545)
#001: Afitos (338)
#002: Agia Paraskevi (548)
...
#142: Volos town (473)
#143: Vourvourou (420)
#144: Vrachos- Loutsa (922)

这篇关于PHP Bad Request在Curl上的SOAP接口http://www.cyberlogic.gr/webservices/PlaceSearch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆