dongzhuang6177 2013-09-05 13:25 采纳率: 100%
浏览 71
已采纳

PHP - WSDL:找不到任何可用的绑定服务

I am trying to set a soap server in php. It seems to work fine without the WSDl. When I point the server to the wsdl it gives me the following error:

Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Could not find any usable binding services in WSDL.

I have searched the web for a possible solution but none of the answers helped.

Following my test wsdl:

 <?xml version='1.0' encoding='UTF-8'?>
<definitions name="WSDLExample" targetNamespace="urn:WSDLExample" xmlns:typens="urn:WSDLExample" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
    <message name="doHello">
        <part name="yourName" type="xsd:string"></part>
    </message>
    <message name="doHelloResponse">
        <part name="doHelloReturn" type="xsd:string"></part>
    </message>
    <message name="index"></message>
    <message name="indexResponse">
        <part name="indexReturn" type="xsd:boolean"></part>
    </message>
    <portType name="ApiPortType">
        <operation name="doHello">
            <documentation>Gives your name back</documentation>
            <input message="typens:doHello"></input>
            <output message="typens:doHelloResponse"></output>
        </operation>
        <operation name="index">
            <documentation>This is awesome1</documentation>
            <input message="typens:index"></input>
            <output message="typens:indexResponse"></output>
        </operation>
    </portType>
    <binding name="ApiBinding" type="typens:ApiPortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding>
        <operation name="doHello">
            <soap:operation soapAction="urn:ApiAction"></soap:operation>
            <input>
                <soap:body namespace="urn:WSDLExample" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></soap:body>
            </input>
            <output>
                <soap:body namespace="urn:WSDLExample" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></soap:body>
            </output>
        </operation>
        <operation name="index">
            <soap:operation soapAction="urn:ApiAction"></soap:operation>
            <input>
                <soap:body namespace="urn:WSDLExample" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></soap:body>
            </input>
            <output>
                <soap:body namespace="urn:WSDLExample" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></soap:body>
            </output>
        </operation>
    </binding>
    <service name="WSDLExampleService">
        <port name="ApiPort" binding="typens:ApiBinding">
            <soap:address></soap:address>
        </port>
    </service>
</definitions>

Thank you!

Edit:

I have found that problem, it was the service that was set not correctly. Now the error is:

[WSDL] SOAP-ERROR: Parsing WSDL: No location associated with

I guess it is still something related to the service.

Here is the server code:

error_reporting(0);
require_once(APPPATH . "/libraries/wsdl/WSDLCreator.php"); //Path to the library
$test = new WSDLCreator("WSDLExample", "http://localhost/soapWrap/wsdl");
$test->setClassesGeneralURL("http://localhost/soapWrap");

$test->includeMethodsDocumentation(TRUE);
$test->addFile(APPPATH . "controllers/api.php");

$test->addURLToClass("api", 'http://localhost/soapWrap/');
$test->addURLToTypens("XMLCreator", "http://localhost/soapWrap");


$test->createWSDL();

$test->printWSDL(true); // print with headers

I have also updated the wsdl with the new one.

Thanks.

  • 写回答

1条回答 默认 最新

  • doulun9534 2013-09-06 08:26
    关注

    I have found the problem(s).

    First of all, I am using CodeIgniter and a library I found on the web for generating the WSDL.

    The problem was with the 'service' tag.

    I had to use the methods:

    "addURLToClass" and "addURLToTypens" to set it up.

    But since that library is not meant to work with CI, I had to play a bit the code. The problem was in the WSDLCreator.php page, changing the passed class to be the CI controller and then using the class inside it. That's all.

    This is the actual code:

    $classLower = strtolower($class);
    $url = isset($this->classesURLS[$class]) ? $this->classesURLS[$class] : $this->classesGeneralURL;
    $port = new XMLCreator("port");
    $port->setAttribute("name", $class."Port");
    $port->setAttribute("binding", "typens:".$class."Binding");
    $soap = new XMLCreator("soap:address");
    isset($this->classesURLS[$classLower]) ? $soap->setAttribute("location", $this->classesURLS[$classLower]) : "";
    $port->addChild($soap);
    

    If you need more info about the code, let me know.

    Thanks for the help! Andrea

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 arduino控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥85 maple软件,solve求反函数,出现rootof怎么办?
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题