wsdl文件要求,如下:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:sch="http://trace.bnet.cn/locRes"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="http://trace.bnet.cn/locRes"
    targetNamespace="http://trace.bnet.cn/locRes">
    <wsdl:types>
        <schema xmlns="http://www.w3.org/2001/XMLSchema"
            attributeFormDefault="unqualified" elementFormDefault="qualified"
            targetNamespace="http://trace.bnet.cn/locRes">
            <element name="locationResponseRequest">
                <complexType>
                    <sequence>
                        <element name="locationRequestID" type="string" />
                        <element name="locResults" type="string" />
                    </sequence>
                </complexType>
            </element>
            <element name="locationResponseResponse" type="string" />
        </schema>
    </wsdl:types>
    <wsdl:message name="locationResponseResponse">
        <wsdl:part element="tns:locationResponseResponse"
            name="locationResponseResponse">
        </wsdl:part>
    </wsdl:message>
    <wsdl:message name="locationResponseRequest">
        <wsdl:part element="tns:locationResponseRequest"
            name="locationResponseRequest">
        </wsdl:part>
    </wsdl:message>
    <wsdl:portType name="LocRes">
        <wsdl:operation name="locationResponse">
            <wsdl:input message="tns:locationResponseRequest"
                name="locationResponseRequest">
            </wsdl:input>
            <wsdl:output message="tns:locationResponseResponse"
                name="locationResponseResponse">
            </wsdl:output>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="LocResSoap11" type="tns:LocRes">
        <soap:binding style="document"
            transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="locationResponse">
            <soap:operation soapAction="" />
            <wsdl:input name="locationResponseRequest">
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output name="locationResponseResponse">
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="LocResService">
        <wsdl:port binding="tns:LocResSoap11" name="LocResSoap11">
            <soap:address
                location=" " />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>接口名,叫locationResponse 这个,接收两个参数,发求发布的wsdl文件如上一样,谢谢了webservicephpsoap

解决方案 »

  1.   

    1、设 WSDL 文件名为 LocRes.wsdl,服务端程序名为 LocRes.php
      均放在网站的 soap 目录下
      修改 wsdl 文件最后一节为
        <wsdl:service name="LocResService">
            <wsdl:port binding="tns:LocResSoap11" name="LocResSoap11">
                <soap:address
                    location="http://localhost/soap/LocRes.php" />
            </wsdl:port>
        </wsdl:service>
      实际使用时需安真实域名、路径填写
    2、服务端程序 LocRes.phpclass Service{
        public function locationResponse($in) {
          //这里是实际处理的代码
          return "param:$in->locationRequestID $in->locResults";
        }
    }$server = new SoapServer('LocRes.wsdl');
    $server -> setClass("service");
    $server -> handle();3、测试用客户端代码
    $url = 'http://localhost/soap/LocRes.php?WSDL';
    $soapClient = new soapclient($url);$a = array(
      'locationRequestID' => 2,
      'locResults' => 'abcd',
    );echo $soapClient->locationResponse($a);
    得到
    param:2 abcd
      

  2.   

    楼上的哥们,你有测试过吗?我这边报了一个错
    Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in E:\phproot\Card01\app\service\index.php:11 Stack trace: #0 E:\phproot\Card01\app\service\index.php(11): SoapClient->__call('locationRespons...', Array) #1 E:\phproot\Card01\app\service\index.php(11): SoapClient->locationResponse(Array) #2 {main} thrown in
    麻烦,你看一下呢?
      

  3.   

    哥们,别生气啊,我有点着急了.
    想问一下,java 调我这个webservice ,怎么说not found ,404错误呢?有解决方法吗
      

  4.   

    1、确认你的java程序没有问题
    比如说访问 http://www.webxml.com.cn/WebServices/ChinaStockWebService.asmx?wsdl2、确认你的服务端程序能通过php的客户端测试
      

  5.   

    java 那边,他们的接口写了,好久的,这个应该没有问题,他们说,很多人,都在调用,我们这边也没有问题 这个是我用php本地调的ini_set ( "soap.wsdl_cache_enabled", "0" );
    $soapClient = new soapclient('http://sanchen.ismartinfo.cn/findeasy/soap/soap.wsdl');
    $list = $soapClient->__getFunctions();
    print_r($list);$a = array(
      'locationRequestID' => 2,
      'locResults' => 'abcd',
    );
     echo $soapClient->locationResponse(array('locationRequestID'=>565656,'locResults'=>'121212'));
      

  6.   

    那你像这样加个协议版本看看
    $server = new SoapServer('LocRes.wsdl', array('soap_version' => SOAP_1_2));
      

  7.   

    哥们,先谢谢了,之前写这个也是有加版本的,但是还是不行,我是这样子写的
    ini_set("soap.wsdl_cache_enabled", "0");
    class service{
        public function locationResponse($in) {
          //这里是实际处理的代码
          file_put_contents("bb.txt","param:$in->locationRequestID $in->locResults");
          return "<?xml version=\"1.0\" encoding=\"utf-8\"?><result><code>0</code><desc></desc></result>";
        }
    }
    $server=new SoapServer('soap.wsdl',array('soap_version' => SOAP_1_2));   //创建SoapServer对象
    $server -> setClass("service");
    $server -> handle();
      

  8.   

    不是很清楚了,按理说应该声明 locationResponse 返回 xml 才对 
      

  9.   

    你好,声明locationResponse,应该怎么申明?我不是很明白
      

  10.   

    我的意思是:一般返回 xml 串的方法,返回的数据类型都声明为 xml 而不是 string你的 wsdl 是什么工具生成的?
    他们的 java 代码是工具生成的吗?soap 技术源于微软,对书写格式要求还是比较严格的。稍有不慎就要出错
    所以一般都用工具生成 wsdl,然后用工具从 wsdl 生成服务端代码和客户端代码php 由于没有提供生成工具,所以产生的服务可能并不标准
      

  11.   

    哥们,你能提供一个标准的吗,我用的是他们提供的wsdl文件,还是你说的,我是直接,改的wsdl文件