添加服务参考TWO服务显示但应该只有一个

时间:2012-01-23 19:21:48

标签: wcf web-services

我正在创建一个基于SOAP的Web服务。我相信服务运行得很好,我启动它,编译,向我展示wsdl,我应该很好。

当我创建测试客户端控制台程序和“添加服务引用”时,我看到TWO而不是我创建的ONE。

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);

}

1 个答案:

答案 0 :(得分:1)

为什么您的服务名称是私有字符串[] textField;您的web.config中的DataContract.oseo?不应该是GetCapabilities