Yii Framework Forum: Nginx+Soap web service - HTTP request failed - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Nginx+Soap web service - HTTP request failed nginx web service error Rate Topic: -----

#1 User is offline   cs24 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 21-January 11

Posted 12 July 2017 - 10:19 AM

Hi,

I've created a new/empty Yii 1.1.x project to test the use of WS in Yii (http://www.yiiframew...pics.webservice)

SiteController.php
	 public function actionWebservice()
	 {
		$client=new SoapClient('http://yiisoap/index.php?r=stock/quote', array(
			'soap_version' => SOAP_1_2,
			'cache_wsdl' =>  WSDL_CACHE_NONE,
			'trace' => 1,
		));

		echo $client->getPrice('GOOGLE');
		echo $client->__getLastRequest();
		echo $client->__getLastResponse();
	 }


StockController.php
	public function actions()
	{
		return array(
			'quote'=>array(
					'class'=>'CWebServiceAction',
			),
		);
	}

 	/**
	 * @param string the symbol of the stock
	 * @return float the stock price
	 * @soap
	 */
	public function getPrice($symbol)
	{
		$prices=array('IBM'=>100, 'GOOGLE'=>350);
		return isset($prices[$symbol])?$prices[$symbol]:0;
	}



http://yiisoap/index.php?r=stock/quote
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:StockControllerwsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="StockController" targetNamespace="urn:StockControllerwsdl">
   <wsdl:message name="getPriceIn">
      <wsdl:part name="symbol" type="xsd:string" />
   </wsdl:message>
   <wsdl:message name="getPriceOut">
      <wsdl:part name="return" type="xsd:float" />
   </wsdl:message>
   <wsdl:portType name="StockControllerPortType">
      <wsdl:operation name="getPrice">
         <wsdl:documentation />
         <wsdl:input message="tns:getPriceIn" />
         <wsdl:output message="tns:getPriceOut" />
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="StockControllerBinding" type="tns:StockControllerPortType">
      <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
      <wsdl:operation name="getPrice">
         <soap:operation soapAction="urn:StockControllerwsdl#getPrice" style="rpc" />
         <wsdl:input>
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:StockControllerwsdl" />
         </wsdl:input>
         <wsdl:output>
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:StockControllerwsdl" />
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="StockControllerService">
      <wsdl:port name="StockControllerPort" binding="tns:StockControllerBinding">
         <soap:address location="http://yiisoap/index.php?r=stock/quote&ws=1" />
      </wsdl:port>
   </wsdl:service>
</definitions>


then, I try to call the ws from http://yiisoap/index...site/webservice and get an error :(
SoapClient::SoapClient(http://yiisoap/index.php?r=stock/quote): failed to open stream: HTTP request failed!


nginx.conf
	server {
		listen       80;
		server_name  yiisoap;

		root   "C:/server/www/yiisoap";
		index  index.php;

		log_not_found off;
		charset utf-8;

		access_log  logs/access.log  main;

		location / {
			index  index.php index.html index.htm;
			try_files $uri $uri/ /index.php?$args;
		}

		error_page   500 502 503 504  /50x.html;
		location = /50x.html {
			root   www;
		}

		location ~ \.php$ {
			try_files      $uri =404;
			fastcgi_pass   php;
			fastcgi_index  index.php;
			#fastcgi_param  PHP_FCGI_MAX_REQUESTS 1000;
			#fastcgi_param  PHP_FCGI_CHILDREN 100;
			fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
			fastcgi_param   REMOTE_ADDR $http_x_real_ip;
			include        fastcgi_params;
		}

		location ~* ^.+.(gif|ico|jpg|jpeg|png|flv|swf|pdf|mp3|mp4|xml|txt|js|css)$ {
			expires 30d;
			add_header Vary Accept-Encoding;
		}

		if ($request_method !~ ^(GET|HEAD|POST)$ ){ return 405; }

		location ~ /(\.ht|\.git|\.svn) {
			access_log off;
			log_not_found off;
			deny  all;
		}
	}


I'm on Windows 8 with nginx 1.9.4 & php 5.6

How can I fix this? :mellow:

Thanks. Regards,
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users