从Silverlight调用WCF服务时获取端点

时间:2013-05-01 16:26:38

标签: vb.net wcf silverlight

我遇到了WCF服务的终点问题。我编写了该服务并使用Windows窗体项目进行了测试。这很好。当我尝试从Silverlight开始工作时会出现问题。导致问题的陈述是

Dim l_svcOOA As SvcZipStreamClient = New SvcZipStreamClient(“BasicHttpBinding_IServiceZipStream”)

错误说

在ServiceModel客户端配置部分找不到名为“BasicHttpBinding_IServiceZipStream”的端点元素和合同“svcZipStream.ISvcZipStream”。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。 System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint,String configurationName)的堆栈跟踪    在System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)    at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName,EndpointAddress address)    在System.ServiceModel.ChannelFactory 1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) at System.ServiceModel.EndpointTrait 1.CreateSimplexFactory()    在System.ServiceModel.EndpointTrait 1.CreateChannelFactory() at System.ServiceModel.ClientBase 1.CreateChannelFactoryRef(EndpointTrait 1 endpointTrait) at System.ServiceModel.ClientBase 1.InitializeChannelFactoryRef()    在System.ServiceModel.ClientBase`1..ctor(String endpointConfigurationName)    at Common.svcZipStream.SvcZipStreamClient..ctor(String endpointConfigurationName)    at Common.clsUtilities.GetFileInZip(String p_ZipFile,String p_FileName)

ServiceReferences.ClientConfig是:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_ISvcZipStream" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:22214/ServiceZipStream.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISvcZipStream"
            contract="svcZipStream.ISvcZipStream" name="BasicHttpBinding_ISvcZipStream" />
    </client>
</system.serviceModel>

与往常一样,任何帮助都将受到赞赏。

1 个答案:

答案 0 :(得分:0)

我只是想让你知道我发现了问题。因为对服务的调用来自Silverlight类库,所以我还需要端点定义的Silverlight应用程序。我在下面的博客中找到了答案。

http://chanmingman.wordpress.com/2011/04/04/could-not-find-endpoint-element-with-name-basichttpbinding_iservice-and-contract-servicereference1-iservice-in-the-servicemodel-client-configuration-section-this-might-be-because-no-configura/