我創建新的網站(而不是web項目), 在Solution Explorer中右擊項目,並點擊添加服務引用服務引用找不到
,我已經添加Web服務提供者地址,創建一個名爲的新文件夾App_WebReferences。它包含ServiceReference1文件夾,其中有三個文件(兩個.svcinfo和一個.wsdl)。
現在我使用此代碼爲我提供指導:
var srv = new ServiceReference1.PaymentIFBindingSoapClient();
double result = srv.verifyTransaction(refNum, "10004738");
存在編譯沒有錯誤,並在本地主機上運行。 但 當我在我的網站上的文件上傳到我的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>
它也應該在子文件夾中工作。你唯一需要做的是在子文件夾上創建一個應用程序:http://technet.microsoft.com/en-us/library/cc772042(v=ws.10).aspx – Kai 2013-04-24 11:46:34
你是一個生活品味感謝; )) – 2016-07-22 13:55:12