2

ここ数時間、WSDLWebサービスをVisualStudio 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が私に提供できるすべての小さなことを試しました:

  1. 「参照されるアセンブリでタイプを再利用する」を無効にする
  2. コレクションタイプをsystem.collections.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メソッドから結果を出力します。

4

1 に答える 1

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>

于 2012-08-05T17:40:31.217 に答える