Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
编辑wsdl以在asp.net中使用php web服务_Php_Asp.net_Web Services_Wsdl - Fatal编程技术网

编辑wsdl以在asp.net中使用php web服务

编辑wsdl以在asp.net中使用php web服务,php,asp.net,web-services,wsdl,Php,Asp.net,Web Services,Wsdl,我在asp.NETWebAPI项目中使用php web服务(我无法修改)时遇到问题。我尝试使用“添加服务引用”和“添加web引用”,但仍然不起作用。我试图找到一个解决方案,解释如何编辑或重构wsdl文件(我在本地保存了该文件),以便使用它来使用服务。我发现了另一个类似的线程,但没有一个解决方案可以帮助我。我的问题与.NET 2.0的问题非常相似,但我使用的是.NET 4.5: 以下是我的错误消息: The document at the url file:xxx was not recogni

我在asp.NETWebAPI项目中使用php web服务(我无法修改)时遇到问题。我尝试使用“添加服务引用”和“添加web引用”,但仍然不起作用。我试图找到一个解决方案,解释如何编辑或重构wsdl文件(我在本地保存了该文件),以便使用它来使用服务。我发现了另一个类似的线程,但没有一个解决方案可以帮助我。我的问题与.NET 2.0的问题非常相似,但我使用的是.NET 4.5:

以下是我的错误消息:

The document at the url file:xxx was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'The root element of a W3C XML Schema should be <schema> and its     namespace should be 'http://www.w3.org/2001/XMLSchema'.'.
- Report from 'DISCO Document' is 'Discovery document at the URL file:xxx could not be found.'.
- The document format is not recognized.
- Report from 'WSDL Document' is 'There is an error in XML document (29, 6).'.
- The element was not expected in this context: <xsd:element     xmlns:xsd='http://www.w3.org/2001/XMLSchema'>..</xsd:element>. Expected elements:   http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:choice,  http://www.w3.org/2001/XMLSchema:group, http://www.w3.org/2001/XMLSchema:all,      http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:attributeGroup,     http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:anyAttribute.
url文件xxx处的文档未被识别为已知文档类型。
来自每种已知类型的错误消息可能有助于解决问题:
-来自“XML模式”的报告是“W3C XML模式的根元素应该是,其命名空间应该是”http://www.w3.org/2001/XMLSchema'.'.
-来自“DISCO文档”的报告是“URL文件中的发现文档:找不到xxx”。
-无法识别文档格式。
-来自“WSDL文档”的报告是“XML文档(29,6)中存在错误”。
-此上下文中不应包含元素:。。。预期要素:http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:choice,  http://www.w3.org/2001/XMLSchema:group, http://www.w3.org/2001/XMLSchema:all,      http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:attributeGroup,     http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:anyAttribute.
第28至30行为:

<xsd:element name="WSData" type="tns:WSData" datos="WSData"/>
  <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:WSData[]"/>
</xsd:restriction>

以下是我的整个wsdl文件:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl: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:tns="https://oneurl.tv/urlexists/1045_APPmobileApp/wsdl/WSDLEnvio.php" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="https://oneurl.tv/urlexists/1045_APPmobileApp/wsdl/WSDLEnvio.php">
<wsdl:types>
<xsd:schema targetNamespace="https://oneurl.tv/urlexists/1045_APPmobileApp/wsdl/WSDLEnvio.php"
>
 <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
 <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
 <xsd:complexType name="WSDataIN">
  <xsd:all>
   <xsd:element name="user" type="xsd:string" datos="user"/>
   <xsd:element name="password" type="xsd:string" datos="password"/>
   <xsd:element name="message" type="xsd:string" datos="message"/>
   <xsd:element name="datetime" type="xsd:string" datos="datetime"/>
   <xsd:element name="messageid" type="xsd:string" datos="messageid"/>
  </xsd:all>
 </xsd:complexType>
 <xsd:complexType name="WSData">
  <xsd:all>
   <xsd:element name="codigores" type="xsd:string" datos="codigores"/>
   <xsd:element name="descrres" type="xsd:string" datos="descrres"/>
  </xsd:all>
 </xsd:complexType>
 <xsd:complexType name="WSDataArray">
  <xsd:complexContent>
   <xsd:restriction base="SOAP-ENC:Array">
   <xsd:element name="WSData" type="tns:WSData" datos="WSData"/>
    <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:WSData[]"/>
   </xsd:restriction>
  </xsd:complexContent>
 </xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="EnviaSMSRequest">
  <part name="datos" type="tns:WSDataIN" />    <wsdl:/message>
<wsdl:message name="EnviaSMSResponse">
  <part name="return" type="tns:WSData" />    <wsdl:/message>
<wsdl:portType name="WSEnvioSMSPortType">
  <operation name="EnviaSMS">
    <documentation>Envia SMS a clientes    </documentation>
    <input message="tns:EnviaSMSRequest"/>
    <output message="tns:EnviaSMSResponse"/>
  </operation>
</wsdl:portType>
<wsdl:binding name="WSEnvioSMSBinding" type="tns:WSEnvioSMSPortType">
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
  <operation name="EnviaSMS">
    <soap:operation soapAction="https://oneurl.tv/urlexists/1045_APPmobileApp/wsdl/WSDLEnvio.php?wsdl#EnviaSMS" style="rpc"/>
    <input>    <soap:body use="encoded" namespace="https://oneurl.tv/urlexists/1045_APPmobileApp/wsdl/WSDLEnvio.php?wsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>    </input>
    <output>    <soap:body use="encoded" namespace="https://oneurl.tv/urlexists/1045_APPmobileApp/wsdl/WSDLEnvio.php?wsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>    </output>
  </operation>
</wsdl:binding>
<wsdl:service name="WSEnvioSMS">
  <port name="WSEnvioSMSPort" binding="tns:WSEnvioSMSBinding">
    <soap:address location="https://oneurl.tv:443/urlexists/1045_APPmobileApp/wsdl/WSDLEnvio.php"/>
  </port>
</wsdl:service>
</wsdl:definitions>

Envia短信服务客户
非常感谢您,我感谢您的建议。

好吧,我解决了!(我是之前问过这个问题的同一位cxnv,但根据stackoverflow标准,我似乎是一个非常糟糕的贡献者,我当然不知道为什么,但是……这是我的答案,我只是不想看到它没有解决)

幸运的是,我发现服务没有使用WSDataArray complexType,所以我在wsdl中删除了它,并将修改后的wsdl导入到我的asp.net项目中(如果使用了WSDataArray,我仍然不知道该怎么办)。但后来我遇到了一个问题,因为响应是用iso-8859-1编码的,所以我在下面修复了它,瞧

教训是永远避免在php中公开web服务!!这本书的作者对此做了很好的解释:

“PHP是一种弱类型语言(…),因此不可能通过反射来生成WSDL文件。这严重限制了PHP作为web服务平台的适用性,因为它妨碍了PHP web服务与用其他语言编写的客户端的轻松互操作性。”

在这种情况下,我无法访问服务来源,但我希望我的合作伙伴在将来考虑这一建议