wsdl:<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"  
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://192.168.1.59:81/soap66fuwu/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"  
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"  
targetNamespace="http://192.168.1.59:81/soap66fuwu/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
  <s:schema elementFormDefault="qualified" targetNamespace="http://192.168.1.59:81/soap66fuwu/">
  <s:element name="DataSet" nillable="true">
  <s:complexType>
  <s:sequence>
  <s:element ref="s:schema" />
  <s:any />
  </s:sequence>
  </s:complexType>
  </s:element>
  </s:schema>
  </wsdl:types>
  <wsdl:message name="getStationAndTimeByStationNameHttpPostIn">
  <wsdl:part name="StartStation" type="s:string" />
  <wsdl:part name="ArriveStation" type="s:string" />
  <wsdl:part name="UserID" type="s:string" />
  </wsdl:message>
  <wsdl:message name="getStationAndTimeByStationNameHttpPostOut">
  <wsdl:part name="Body" element="tns:DataSet" />
  </wsdl:message>
  <wsdl:portType name="TrainTimeWebServiceHttpPost">
  <wsdl:operation name="getStationAndTimeByStationNamePost">
  <wsdl:input message="tns:getStationAndTimeByStationNameHttpPostIn" />
  <wsdl:output message="tns:getStationAndTimeByStationNameHttpPostOut" />
  </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="TrainTimeWebServiceHttpPost" type="tns:TrainTimeWebServiceHttpPost">
  <http:binding verb="POST" />
  <wsdl:operation name="getStationAndTimeByStationNamePost">
  <http:operation location="/getStationAndTimeByStationNamePost" />
  <wsdl:input>
  <mime:content type="application/x-www-form-urlencoded" />
  </wsdl:input>
  <wsdl:output>
  <mime:mimeXml part="Body" />
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="TrainTimeWebService">
  <wsdl:port name="TrainTimeWebServiceHttpPost" binding="tns:TrainTimeWebServiceHttpPost">
  <http:address location="http://192.168.1.59:81/soap66fuwu/testTrainService.php" />
  </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
php服务端代码 testTrainService.php
<?
 public function getStationAndTimeByStationNamePost($StartStation , $ArriveStation, $UserID){  
$xml = "<root><title>dataFromSoapReturn</title></root>";  
  return array(array("schema"=>"","any"=>$xml));
 }
?>form post 数据:<form target="_blank" action='http://192.168.1.59:81/soap66fuwu/testTrainService.php/getStationAndTimeByStationNamePost' method="post">   
post字符串: StartStation=aa&ArriveStation=aa&UserID=a程序报错:SOAP-ENV:ClientBad Request我想问的关键问题,是post的数据的变量串  怎么 传到服务端去,而且变量 怎么能格式化为 一一对应到服务端的函数当中去

解决方案 »

  1.   

    服务器端不用$_POST来取参数
    你用php的SoapServer建立服务端后,弄一个这样的函数:
    function getStationAndTimeByStationNamePost($params)
    {
    var_dump($params);
    }然后用SoapServer->addFunction添加
    你把$params的内容打出来你就明白了。
    php把所有请求的数据放在一个大数组里,按每个层级的标签,分别是数组的键。你可以用一个这个工具:soapui
      

  2.   

    1楼的想法我当然试过,可是发请求的时候,请求就发出去,火狐的DEBUG报的SOAP错误<?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Bad Request</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>是SOAP的参数请求异常,可是 我是以POST方式提交参数的。郁闷了好长时间,不知道如何解决,JAVA的AXIS2,和XFIRE,生成的代码 都可以实现POST GET方式 调用WEBSERVICE,PHP我就在串参数的地方卡主了
      

  3.   

    testTrainService.php 服务端的代码是这样的
    class calendarAPI {
    //post
    public function getStationAndTimeByStationNamePost($StartStation){
    error_log(print_r($StartStation,true),3,"getStationAndTimeByStationNamePost.log");
    $xml = "<root><title>dataFromSoapReturn</title><content><StartStation>".$StartStation."</StartStation><ArriveStation>".'$ArriveStation'."</ArriveStation><UserID>".'$UserID'."</UserID></content></root>"; 
    return array("schema"=>"","any"=>$xml);
    }

    }$servidorSoap = new SoapServer("http://192.168.106.59:82/soap66fuwu/trianxml.wsdl");
    //$servidorSoap->addFunction(getStationAndTimeByStationNamePost);
    $servidorSoap->setClass("calendarAPI");
    $servidorSoap->handle();我用POST表单提交数据html如下:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head><body>
    <!-- http://www.webxml.com.cn/WebServices/TrainTimeWebService.asmx/getStationAndTimeByStationName-->
    <!-- http://192.168.106.59:82/soap66fuwu/testHttpService.php/getStationAndTimeByStationName-->
    <!-- http://192.168.106.59:82/soap66fuwu/testTrainService.php/getStationAndTimeByStationNameGet-->
    <form target="_blank" action='http://192.168.106.59:82/soap66fuwu/testTrainService.php/getStationAndTimeByStationNamePost' method="POST"> 
      <p>
        <label>StartStation:
          <input type="text" name="StartStation" id="StartStation" />
        </label>
      </p>
      <p>
        <label>ArriveStation:
          <input type="text" name="ArriveStation" id="ArriveStation" />
        </label>
      </p>
      <p>
        <label>UserID:
          <input type="text" name="UserID" id="UserID" />
        </label>
      </p>
      <p>
        <label>
          <input type="submit" value="提交" />
        </label>
      </p>
    </form>
    </body>
    </html>
    麻烦给出点意见,是我的WSDL写错了,还是 SERVER 错误,还是我提交的HTML错误      0(>_<)0