1

我创建了新网站(不是 web 项目),在解决方案资源管理器中右键单击项目并单击添加服务参考

然后我添加了一个 Web 服务提供商地址,创建了一个名为App_WebReferences的新文件夹。它包含 ServiceReference1 文件夹,其中包含三个文件(两个 .svcinfo 和一个 .wsdl)。

现在我使用此代码作为我的提供者指导:

var srv = new ServiceReference1.PaymentIFBindingSoapClient();
double result = srv.verifyTransaction(refNum, "10004738");

在localhost中编译和运行没有错误。但是当我将网站文件上传到服务器上的 ftp 时。我收到以下错误消息

*Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 
**Compiler Error Message:** CS0246: The type or namespace name 'ServiceReference1'     could not be found (are you missing a using directive or an assembly reference?)
Source Error:

Line 69:             ///WebService Instance
Line 70:             //
Line 71:             var srv = new ServiceReference1.PaymentIFBindingSoapClient();
Line 72:             
Line 73:             double result = srv.verifyTransaction(refNum, "10004738");

Source File: d:\domains\olomrayaneh.net\wwwroot\ebook\check_payment.aspx.cs    Line: 71 

Show Detailed Compiler Output:
Show Complete Compilation Source:

Version Information: Microsoft .NET Framework Version:2.0.50727.3643; ASP.NET     Version:2.0.50727.3634*

我陷入了这个问题。有什么问题!?我该如何解决?

我应该说我试图添加这一行:

using ServiceReference1;

然后错误消息行更改为具有相同消息的该行!

并且在 localhost 运行中再次没有错误消息!

我的网站是在 .Net Framework 3.5 中构建的

web.config -- 添加服务器引用后,这些行添加到 web.config 文件中:

    <system.serviceModel>
                <bindings>
   <basicHttpBinding>
    <binding name="PaymentIFBindingSoap" 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="PaymentIFBindingSoap1" 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.samanepay.com:2789/payments/referencepayment.asmx"
    binding="basicHttpBinding" bindingConfiguration="PaymentIFBindingSoap"
    contract="ServiceReference1.PaymentIFBindingSoap" name="PaymentIFBindingSoap" />
  </client>
        </system.serviceModel>
4

2 回答 2

2

谢谢朋友。我已经解决了。

问题是我将所有数据复制到 wwwroot 文件夹下的子文件夹中,

但我应该将 App_WebReference 文件夹复制到 wwwroot 文件夹的根目录!

于 2013-04-24T11:30:31.603 回答
0

通常所有服务引用都存储在项目的 web.config 文件中,该文件通常不会部署。只需检查您的服务器 web.config 文件是否还包含对您的服务的引用,如果没有从本地文件中添加它。

于 2013-04-24T07:00:19.603 回答