2013-04-24 86 views
1

我創建新的網站(而不是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> 

回答

2

感謝朋友。 我解決了它。

的問題是,我是所有的數據複製到wwwroot文件夾下的子文件夾,

但我應該App_WebReference文件夾複製到wwwroot文件夾的根!

+0

它也應該在子文件夾中工作。你唯一需要做的是在子文件夾上創建一個應用程序:http://technet.microsoft.com/en-us/library/cc772042(v=ws.10).aspx – Kai 2013-04-24 11:46:34

+0

你是一個生活品味感謝; )) – 2016-07-22 13:55:12

0

通常所有的服務引用都存儲在項目和這個文件的web.config文件通常不會被部署。只要檢查你的服務器web.config文件是否包含對你的服務的引用,如果沒有從你的本地文件中添加它。

+0

感謝您的回答。 我已經添加了web.config更改我的問題。 請檢查它。我應該再做些什麼嗎? – user1422847 2013-04-24 07:35:28

+0

只需比較你的web.config和服務器web.config,但它看起來像你有所有的設置。它工作嗎? – Kai 2013-04-24 07:41:39

+0

我已經將自己的web.config上傳到服務器。但問題在於! 糟糕!搜索2天后無解! 再次感謝。 – user1422847 2013-04-24 09:32:09