0

我正在尝试在 php 中设置一个肥皂服务器。如果没有 WSDl,它似乎可以正常工作。当我将服务器指向 wsdl 时,它给了我以下错误:

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

我在网上搜索了一个可能的解决方案,但没有一个答案有帮助。

在我的测试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>

谢谢!

编辑:

我发现了这个问题,是服务设置不正确。现在错误是:

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

我想这仍然与服务有关。

这是服务器代码:

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

我还用新的更新了 wsdl。

谢谢。

4

1 回答 1

1

我发现了问题。

首先,我使用 CodeIgniter 和我在网上找到的一个库来生成 WSDL。

问题出在“服务”标签上。

我不得不使用以下方法:

“addURLToClass”和“addURLToTypens”来设置它。

但由于该库不适合与 CI 一起使用,所以我不得不玩一些代码。问题出在 WSDLCreator.php 页面中,将传递的类更改为 CI 控制器,然后使用其中的类。就这样。

这是实际的代码:

$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);

如果您需要有关代码的更多信息,请告诉我。

谢谢您的帮助!安德烈亚

于 2013-09-06T08:26:49.127 回答