2
最近幾個小時我一直在努力將WSDL webservice導入到Visual Studio 2010中。慢慢地,我一直在努力通過我的WSDL,解決其他問題直到我遇到了這樣一個:無法導入WSDL服務「targetNamespace」urn:webservice'not found'
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!
我試過每一個微小的小事谷歌可能會提供給我,包括:
- 禁用「重用類型的引用程序」
- 設置集合類型系統.collectio ns.generic.list
- 來回更改大部分屬性。
- 複製從別人WSDL文件,只是爲了看看它是否會工作(它沒有)
這裏是我的.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方法不輸出結果