2012-08-04 307 views
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! 

我試過每一個微小的小事谷歌可能會提供給我,包括:

  1. 禁用「重用類型的引用程序」
  2. 設置集合類型系統.collectio ns.generic.list
  3. 來回更改大部分屬性。
  4. 複製從別人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方法不輸出結果

回答

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> 

相關問題