首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在WSDL中找不到<definitions>

在WSDL中找不到<definitions>
EN

Stack Overflow用户
提问于 2017-08-02 16:34:39
回答 1查看 2.1K关注 0票数 0

我试图开发我的第一个SOAP when服务,但是当我尝试使用wizdl打开我的WSDL时,我遇到了一个错误。我得到了这个错误:

代码语言:javascript
复制
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>WSDL</faultcode>
<faultstring>
SOAP-ERROR: Parsing WSDL: Couldn't find <definitions> in 
'http://localhost/testSolution/test.wsdl'
</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

下面是我的代码: testSolution.php:

代码语言:javascript
复制
 <?php

class Ws{

  function getString()
  {
    return "TESTASTOS";
  }
}

ini_set("soap.wsdl_cache_enabled", 0);

$serversoap = new SoapServer("http://localhost/testSolution/test.wsdl");

$serversoap->setClass("Ws");

$serversoap->handle();

?>

和test.wsdl:

代码语言:javascript
复制
<?xml version="1.0" encoding="iso-8859-1"?>
<definitions
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl"

  targetNamespace="urn:serviceTestwsdl"
  xmlns:tns="urn:serviceTestwsdl"
>


<types>
<xsd:schema targetNamespace="urn:serviceTestwsdl"/>
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
</types>

<message name="getStringRequest">
</message>
<message name="getStringResponse">
<part name="return" type="xsd:string" />
</message>

<portType name="serviceTestPortType">

<operation name="getString">
  <documentation>Récupère un string</documentation>
  <input message="tns:getStringRequest"/>
  <output message="tns:getStringResponse"/>
</operation>
</portType>


<binding name="serviceTestBinding" type="tns:serviceTestPortType">

 <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
 <operation name="getString">
  <soap:operation soapAction="urn:serviceTestwsdl#getString" style="rpc"/>
  <input>
    <soap:body use="encoded" namespace="urn:serviceTestwsdl" 
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  </input>
  <output>
    <soap:body use="encoded" namespace="urn:serviceTestwsdl" 
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  </output>
</operation>
</binding>

<service name="serviceTest">
<port name="serviceTestPort" binding="tns:serviceTestBinding">
  <soap:address location="http://localhost/testSolution/testSolution.php"/>
</port>

</service>
</definitions>

主要目标是通过在字符串上创建一个小的hello world来理解soap work服务是如何工作的。

非常感谢你的帮助

致以问候。迪迪埃

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-02 17:22:38

您需要在test.wsdl中添加"wsdl“前缀,如<wsdl:definitions>。也是该参数中的第一级元素:

代码语言:javascript
复制
<wsdl:types>...</wsdl:types>
<wsdl:operation>...</wsdl:operation>

..。等

这将允许您加载wsdl。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45455630

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档