过去几个小时我一直在努力将WSDL Web服务导入Visual Studio 2010.慢慢地,我一直在努力完成我的WSDL,解决其他问题,直到我遇到这个问题:
Warning 1 Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension:
System.ServiceModel.Description.XmlSerializerMessageContractImporter
Error: Schema with target namespace 'urn:WebService' could not be found.
XPath to Error Source:
//wsdl:definitions[@targetNamespace='urn:WebService']/wsdl:portType[@name='DataPort']
C:\* blablabla *\WeGotchaService\Reference.svcmap 1 1 Gotcha!
我已经尝试过Google可以为我提供的所有小东西,包括:
这是我的.wsdl文件:
<?xml version="1.0"?>
<definitions
name="WebService"
targetNamespace="urn:WebService"
xmlns:tns="urn:WebService"
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/">
<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="GetData">
<xsd:element name="getCustomerID" type="xsd:int" />
<xsd:element name="DataResponse" type="xsd:string" />
</xsd:schema>
</types>
<message name="doGetCustomerID">
<part name="ID" type="tns:getCustomerID" />
</message>
<message name="doDataResponse">
<part name="return" type="tns:DataResponse" />
</message>
<portType name="DataPort">
<operation name="getData">
<input message="tns:doGetCustomerID" />
<output message="tns:doDataResponse" />
</operation>
</portType>
<binding name="DataBinding" type="tns:DataPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="getData">
<soap:operation soapAction="urn:getDataAction" />
<input>
<soap:body use="encoded" namespace="urn:GetData" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded" namespace="urn:GetData" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="WeGotchaService">
<port name="DataPort" binding="tns:DataBinding">
<soap:address location="http://localhost/weGotcha/servicehandler.php" />
</port>
</service>
</definitions>
Servicehandler.php
<?php
if(!extension_loaded("soap"))
{
dl("php_soap.dll");
}
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("getPersonen.wsdl");
function getData($persoon_id)
{
mysql_connect("localhost", "root", "");
mysql_select_db('gotcha_dbtemplate');
$sql = "SELECT * FROM lessen";
$sql = mysql_query($sql);
while($row = mysql_fetch_array($sql))
{
$result[] = $row;
}
mysql_close();
return $result;
}
$server->addFunction("getData");
$server->handle();
?>
我不知道如何解决这个问题。还有一些其他错误,但这些是因为导入portType时遇到问题(绑定导入错误,因为portType不正常,端口错误,因为依赖于绑定)
我希望有人知道问题是什么,我不知道:( 感谢。
更新:我的test.php运行正常,它确实输出了getData方法的结果。
答案 0 :(得分:0)
我已经改变了很多,我无法记住,现在它有效:
<?xml version="1.0"?>
<definitions xmlns:tns="http://localhost/weGotcha/servicehandler/wsdl_service.wsdl" 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/" name="WebService" targetNamespace="http://localhost/weGotcha/servicehandler/wsdl_service.wsdl">
<types>
<xs:schema elementFormDefault="qualified" targetNamespace="http://localhost/weGotcha/servicehandler/wsdl_service.wsdl" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://localhost/weGotcha/servicehandler/wsdl_service.wsdl">
<xsd:element name="getCustomerID" type="xsd:int"/>
<xs:complexType name="Persoon">
<xs:sequence>
<xs:element name="ID" type="xsd:int"/>
<xs:element name="Voornaam" type="xsd:string"/>
<xs:element name="Achternaam" type="xsd:string"/>
<xs:element name="Adres" type="xsd:string"/>
<xs:element name="Postcode" type="xsd:string"/>
<xs:element name="Woonplaats" type="xsd:string"/>
<xs:element name="Email_adres" type="xsd:string"/>
<xs:element name="Telefoonnummer" type="xsd:string"/>
<xs:element name="CBR_Kandidaatnummer" type="xsd:string"/>
<xs:element name="Rijbewijs" type="xsd:int"/>
<xs:element name="Laatste_keer_bewerkt" type="xsd:dateTime"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="PersoonList">
<xs:complexContent>
<xs:restriction base="soapenc:Array">
<xs:sequence>
<xs:element name="Persoon" type="tns:Persoon" maxOccurs="unbounded"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
</types>
<message name="doGetCustomerID">
<part name="CustomerID" type="xsd:int"/>
</message>
<message name="doGetPersoonDataResponse">
<part name="return" type="tns:PersoonList"/>
</message>
<portType name="DataPort">
<operation name="getPersoonData">
<input message="tns:doGetCustomerID"/>
<output message="tns:doGetPersoonDataResponse"/>
</operation>
</portType>
<binding name="DataBinding" type="tns:DataPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getPersoonData">
<soap:operation soapAction="urn:getDataAction"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:GetData"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:GetData"/>
</output>
</operation>
</binding>
<service name="WeGotchaService">
<port name="DataPort" binding="tns:DataBinding">
<soap:address location="http://localhost/weGotcha/servicehandler/servicehandler.php"/>
</port>
</service>