2014-09-18 2 views
0

У меня есть библиотека сервиса WCF, которую я размещаю в приложении Windows Forms. Я хотел бы назвать эту услугу с сайта asp.net, размещенного на лазурном веб-сайте. Я создал ссылку на службу в проекте веб-сайта и попытался вызвать некоторые из сервисных функций из кода позади. Когда я делаю это я получаю следующее сообщение об ошибке:Доступ к локальному самообслуживаемому сервису WCF от asp.net Веб-сайт

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 

Моя служба работает, и я могу получить доступ к адресу службы в моем браузере. Можно ли позвонить услуге с веб-сайта?

EDIT:

Моя служба конфигурации:

<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? Это похоже на кандидата в [Azure Service Bus] (http://azure.microsoft.com/en-us/services/service-bus/) –

ответ

0

Для того, чтобы установить архитектуру вы описали, вы должны смотреть на Azure Service Bus, которая «позволяет размещать службы WCF в вашей существующей (локальной) среде и делегировать запросы этим службам WCF v ia служебная шина, работающая в Azure ».

Следующая Microsoft Azure ссылка обеспечивает обзор вашего сценария:

Служба Service Bus Relay позволяет создавать гибридные приложения, которые работают как в лазурных центрах обработки данных и ваша собственной корпоративной среде локальных. Реле Service Bus облегчает это, позволяя вам безопасно предоставлять услуги 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