2014-09-18 155 views
0

我有一個WCF服務庫,我在Windows窗體應用程序中託管。我想從一個在azure網站上託管的asp.net網站調用該服務。我在網站項目中創建了一個服務引用,並試圖從後面的代碼中調用一些服務函數。 當我這樣做,我得到以下錯誤:從asp.net訪問本地自託管WCF服務網站

An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:8732 
    [SocketException (0x271d): An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:8732] 
     System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +208 
     System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +464 

    [WebException: Unable to connect to the remote server] 
     System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) +6543605 
     System.Net.HttpWebRequest.GetRequestStream() +13 
     System.ServiceModel.Channels.WebRequestHttpOutput.GetOutputStream() +55 

    [EndpointNotFoundException: There was no endpoint listening at http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary/ConnectService/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.] 
     System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +10818447 
     System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +336 
     TestProject.ConnectServiceReference.IConnectService.SayHello() +0 

我的服務正在運行,我可以在我的瀏覽器訪問該服務的地址。 是否可以通過網站致電該服務?

編輯:

我的服務配置:

<system.serviceModel> 
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
<services> 
    <service behaviorConfiguration="MyServiceTypeBehaviors" name="WcfServiceLibrary.ConnectService"> 
    <endpoint address="" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IConnectService" name="ServiceEndpoint" contract="WcfServiceLibrary.IConnectService"> 
     <identity> 
     <dns value="localhost" /> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" name="MetaDataEndpoint" contract="IMetadataExchange" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary/ConnectService/" /> 
     </baseAddresses> 
    </host> 
    </service> 
</services> 
<bindings> 
    <basicHttpBinding> 
    <binding name="BasicHttpBinding_IConnectService"/>     
    </basicHttpBinding>  
</bindings>  
<behaviors> 
<serviceBehaviors> 
    <behavior name="MyServiceTypeBehaviors" > 
    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="False" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
</system.serviceModel> 

asp.net的web.config:

<bindings> 
    <basicHttpBinding> 
    <binding name="BasicHttpBinding_IConnectService"> 
     <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="None" proxyCredentialType="Windows" /> 
     </security> 
    </binding> 
    </basicHttpBinding> 
    </bindings> 
<client>  
    <endpoint address="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary/ConnectService/" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IConnectService" 
    contract="ConnectServiceReference.IConnectService" name="BasicHttpBinding_IConnectService" /> 
</client> 
+0

你試圖連接從天青到本地主機?這似乎是[Azure服務總線]的候選人(http://azure.microsoft.com/en-us/services/service-bus/) – 2014-09-18 16:25:03

回答

0

爲了確定您所描述的架構,你應該看看Azure服務總線,它允許您在現有(本地)環境中託管WCF服務並將請求委託給這些WCF服務v ia服務總線在Azure中運行。「

以下微軟Azure的鏈接提供您的方案概述:

服務總線中繼服務,您可以建立在兩個蔚藍的數據中心和您自己的本地企業環境中運行的混合應用。服務總線中繼通過使您能夠將位於企業企業網絡內的Windows Communication Foundation(WCF)服務安全地公開到公共雲而無需打開防火牆連接或要求對企業網絡基礎架構進行侵入式更改,從而爲此提供便利。

http://azure.microsoft.com/en-us/documentation/articles/service-bus-dotnet-how-to-use-relay/

http://blogs.technet.com/b/meamcs/archive/2011/12/23/my-hello-azure-service-bus-wcf-service-step-by-step-guide.aspx

相關問題