2012-01-23 27 views
2

我正在創建基於SOAP的Web服務。我相信該服務運行良好,我開始編譯,向我展示wsdl,我應該很好。添加服務參考顯示兩個服務,但應該只有一個

當我創建一個測試客戶端控制檯程序和「添加服務引用」時,我看到TWO而不是我創建的一個。

enter image description here

任何人都知道可能會導致此行爲?

我相信我的web.config是直截了當的。

<system.serviceModel> 
    <diagnostics wmiProviderEnabled="true"> 
     <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000"/> 
    </diagnostics> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior> 
       <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
       <serviceMetadata httpGetEnabled="true"/> 
       <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
       <serviceDebug includeExceptionDetailInFaults="True" httpHelpPageUrl="~/info.html" httpHelpPageEnabled="True" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <!--<bindings> 
     <basicHttpBinding> 
      <binding name="oseo_basicHTTP_binding"> 
       <readerQuotas maxDepth ="2147483647" 
        maxStringContentLength="2147483647" 
        maxArrayLength="2147483647" 
        maxBytesPerRead="2147483647" 
        maxNameTableCharCount="2147483647" /> 
      </binding> 
     </basicHttpBinding> 
    </bindings>--> 
    <services> 
     <service name="DataContract.oseo"> 
      <host> 
       <baseAddresses> 
        <add baseAddress="http://localhost:56565/oseo.svc" /> 
       </baseAddresses> 
      </host> 
      <endpoint address="" binding="basicHttpBinding" contract="DataContract.Ioseo" /> 
      <!--<endpoint address="" binding="basicHttpBinding" bindingConfiguration="oseo_basicHTTP_binding" contract="DataContract.Ioseo" />--> 
      <endpoint 
       address="mex" 
       binding="mexHttpBinding" 
        contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" > 
     <serviceActivations> 
      <add factory="System.ServiceModel.Activation.ServiceHostFactory" 
       relativeAddress="~/oseo.svc" 
       service="WebServices.oseo"/> 
     </serviceActivations> 
    </serviceHostingEnvironment> 
</system.serviceModel> 

我的代碼太:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 
[System.ServiceModel.ServiceBehavior(Namespace = "https://www.mydomain.com/ogc/oseo")] 
public class oseo : Ioseo 
{ 
    #region GetCapabilities 
    public GetCapabilitiesResponse GetCapabilities(GetCapabilitiesRequest request) 
    { 
     GetCapabilitiesResponse response = null; 

     try 
     { 
      using (OSEO.Capabilities capabilities = new OSEO.Capabilities(request)) 
      { 
       response = capabilities.GetCapabilities(); 
      } 
     } 
     catch (System.Exception ex) 
     { 
      //throw new FaultException<ExceptionReport>(exceptions.GetExceptionReport(), new FaultReason("A server exception was encountered."), new FaultCode("Receiver")); 
     } 
     return response; 
    } 
    #endregion 
} 

編輯#1

我的接口:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] 
[System.ServiceModel.ServiceContractAttribute(Namespace = "https://www.MyDomain.com/ogc/oseo", ConfigurationName = "DataContract.Ioseo")] 
public interface Ioseo 
{ 
    [System.ServiceModel.OperationContract] 
    [System.ServiceModel.FaultContractAttribute(typeof(ExceptionReport), Action = "http://www.w3.org/2005/08/addressing/soap/fault", Name = "ExceptionReport", Namespace = "http://www.opengis.net/ows")] 
    [System.ServiceModel.XmlSerializerFormatAttribute()] 
    GetCapabilitiesResponse GetCapabilities(GetCapabilitiesRequest request); 

} 
+0

爲什麼您的服務名稱爲'private string [] textField; DataContract.oseo' in your web.config?它不應該是'GetCapabilities'嗎? –

+0

有沒有機會添加您的服務和操作定義?不是實現,而是你如何用屬性裝飾你的接口和實現?我根據你的信息把一個快速樣本放在一起,對我來說它工作得很好 - 但我猜測的是奧索的定義。 –

+0

@DavidHoerster:我已經添加了我的界面......那是你在找什麼? – capdragon

回答

1

爲什麼你的服務名稱爲private string [] textField; DataContract.oseo在你的web.config中?難道不是GetCapabilities

+0

是的,它是'DataContract.oseo',我剛把它粘貼在這裏。謝謝(+1)我已經更新了我的原始問題,以讀取'DataContract.oseo'。 – capdragon

+0

np - 謝謝...我不確定這是否會影響任何內容。很高興聽到這是一個錯字。 –