c# - Web 服务创建实例问题 -> 找不到引用契约(Contract) 'MyWebService.ClassName' 的默认端点元素

标签 c# asp.net web-services class

我想使用下面的 Web 服务:

https://acquirer.sb24.com/ref-payment/ws/ReferencePayment?WSDL

并在添加后构建配置文件 ->

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="PaymentIFBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="Transport">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
                <binding name="PaymentIFBinding1" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://acquirer.sb24.com:443/ref-payment/ws/ReferencePayment"
                binding="basicHttpBinding" bindingConfiguration="PaymentIFBinding"
                contract="SB24Service.PaymentIF" name="PaymentIFPort" />
        </client>
    </system.serviceModel>
</configuration>  

我想调用这个 WebService 的 verifyTransaction 方法:

PaymentIFClient pic = new PaymentIFClient();  

double pic_result = pic.verifyTransaction(str1, str2);  

但第一行抛出以下错误:

Could not find default endpoint element that references contract 'SB24Service.PaymentIF' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

编辑:

"This error can arise if you are calling the service in a class library and calling the class library from another project." -> My Situation is like this ...

我应该更改我的配置文件什么?
提前致谢

最佳答案

手动编辑 wcf 配置很棘手,因为有许多部分需要正确并正确地相互引用。尝试在 SvcConfigEditor 中打开您的 app.config 文件(也可从 Viusal Studio 的“工具”菜单中获得)。当有 GUI 帮助做什么时,更容易让事情正确。

关于c# - Web 服务创建实例问题 -> 找不到引用契约(Contract) 'MyWebService.ClassName' 的默认端点元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6787326/

相关文章:

javascript - 使用 IJavaScriptExecutor 时如何 Hook 自定义 javascript 触发器

c# - 使用存储库模式与 Entity Framework 一起使用的自动映射器?

c# - ConcurrentBag 与自定义线程安全列表

java - 用于测试基于 Java soap 的 Web 服务的工具

web-services - 尝试列出服务时 Apache Axis NoClassDefFoundError

c# - Linq - 按 ID 值排序

asp.net - imagebutton onclientclick 和 onclick 事件

c# - 部署时 ASP.net CS1061 编译错误

html - 波浪号 (~) 符号未按预期工作

android - 在网络上上传图像 : getting html source code as response