Hosting Remoto Objects in Serviços de Informações da Internet (IIS)
To Host a remoto objeto in Serviços de Informações da Internet (IIS) You Must Configure the remoto objeto. Normalmente isso é Concluído um dentro uma arquivo de configuração ou programaticamente dentro de código do aplicativo de hospedagem. When a remoto objeto is Hosted within IIS you can Either local the informações configuração a arquivo Web.config or you can programaticamente Configure the remoto objeto in the método Application_Start in the Global. Arquivo ASAX.
Para usar um arquivo de configuração para configurar um objeto remoto, faça o seguinte:
Coloque suas informações de configuração no arquivo web.config no diretório virtual de IIS que você escolheu usar.
Coloque sua implementação tipo remotable no diretório \Bin (ou use o cache global do conjunto de módulos (assembly) ferramenta (Gacutil.exe) colocá-lo no Cache de Conjunto Global).
Ao especificar um arquivo Web.config, a seguir não é suportada:
Especificando um nome de aplicativo, o nome do diretório virtual torna-se o nome do aplicativo.
Usando o elemento https://msdn.microsoft.com/pt-br/library/cdy01964(v=vs.85) < @@ > em um arquivo Web.config que é usado para configuração arquitetura de comunicação remota do.NET.
Using any canalizar Outro than the HttpChannel.
Use o arquivo web.config e o elemento https://msdn.microsoft.com/pt-br/library/b767h4k2(v=vs.85) < cliente > para configurar o cliente de aplicativos da Web automaticamente. If you desejar to Use IIS as a cliente arquitetura de comunicação remota, You Must chamar RemotingConfiguration.Configure in the método Application_Start in the Global. Arquivo ASAX.
The arquivo Web.config still contains the Informações Básicas about Your tipo that the sistema must know, but some Declarations must alteração slightly to acomodar the ambiente de hospedagem. For exemplo, you can Personalizar configure a particular HttpChannel, but you should not especificar a porta for the canalizar; should ASP.NET Criar domínio do aplicativo another to the carregar, the configuração arquitetura de comunicação remota identificador causes that New domínio do aplicativo to Try to escutar on the same porta again, raising an exceção. Por exemplo, um arquivo Web.config para um objeto remoto .NET hospedado pelo IIS pode ser semelhante ao exemplo de código a seguir. It não é necessary to include the Lines configuração canalizar in this maiúsculas e minúsculas, Except to Set the Properties canalizar (in this maiúsculas e minúsculas, the propriedade priority).
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
mode="Singleton"
type="ServiceClass, ServiceClassAssemblyName"
objectUri="ServiceClass.rem"
/>
</service>
<channels>
<channel
name="MyChannel"
priority="100"
ref="http"
/>
</channels>
</application>
</system.runtime.remoting>
</configuration>
Dica
Não especificar uma porta para qualquer canais listados aqui.If you desejar Your aplicativo to escutar on a porta particular, use serviços de Internet Gerente to especificar that escutar IIS on that porta.Is the canalizar you configure automaticamente Used to identificador Remoto requests submitted on that porta.
Para com êxito objetos host servidor-ativadas (isto é, < wellknown >) dentro do IIS, você deve ter um objeto uniforme URI) que termina em .rem ou .soap (identificador de recurso. Não há nenhum tal requisito para outro hospedar Aplicativo domínios. Para usar o Soapsuds ferramenta (Soapsuds.exe) para gerar os metadados de um objeto de servidor-ativado hospedado no IIS, o URL para passar como um argumento para Soapsuds.exe é da seguinte maneira:
http:// < Computador >:< Port >/< VirtDir >/< ObjectURI ≫? WSDL
Para objetos de cliente-ativado hospedados no IIS ou qualquer outro domínio de aplicativo, você não precisa de um objeto URI de qualquer formulário. A URL para passar como um argumento para Soapsuds.exe é da seguinte maneira:
http:// < Computador >:< Port >/< VirtDir ≫ /RemoteApplicationMetadata.rem?WSDL
Programmatic in is Concluído Using the Global.asax. The seguinte exemplo shows the same configuração as the previously shown arquivo de configuração, but uses the Global. Arquivo ASAX.
<%@ Application Language="VB" %>
<%@ Assembly Name="Server" %>
<%@ Import Namespace="System.Runtime.Remoting" %>
<%@ Import Namespace="System.Runtime.Remoting.Channels" %>
<%@ Import Namespace="System.Runtime.Remoting.Channels.Http" %>
<%@ Import Namespace="Server" %>
Sub Application_Start()
Dim props = New Hashtable() As IDictionary
props("name") = "MyChannel"
props("priority") = "100"
' Nothing entries specify the default formatters.
Dim channel As New HttpChannel( _
props, _
Nothing, _
Nothing _
)
ChannelServices.RegisterChannel(channel)
Dim WKSTE As New WellKnownServiceTypeEntry( _
GetType(ServiceClass), _
"HttpService", _
WellKnownObjectMode.SingleCall
)
RemotingConfiguration.RegisterWellKnownServiceType(WKSTE)
End Sub
<%@ Application Language="C#" %>
<%@ Assembly Name="Server" %>
<%@ Import Namespace="System.Runtime.Remoting" %>
<%@ Import Namespace="System.Runtime.Remoting.Channels" %>
<%@ Import Namespace="System.Runtime.Remoting.Channels.Http" %>
<%@ Import Namespace="Server" %>
void Application_Start(){
IDictionary props = new Hashtable();
props["name"] = "MyChannel";
props["priority"] = "100";
// Null entries specify the default formatters.
HttpChannel channel = new HttpChannel(
props,
null,
null
);
ChannelServices.RegisterChannel(channel);
WellKnownServiceTypeEntry WKSTE = new WellKnownServiceTypeEntry(
typeof(ServiceClass),
"HttpService",
WellKnownObjectMode.SingleCall
);
RemotingConfiguration.RegisterWellKnownServiceType(WKSTE);
}
As entradas a seguir devem ser colocadas no arquivo web.config para certificar-se de que os conjuntos de módulos (assemblies) necessários sejam referidos:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation>
<assemblies>
<add assembly="System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
</system.web>
</configuration>
For a Concluir exemplo, see Remoting Example: Hosting in Information Internet Serviços (IIS).
Usando certificados SSL com sistema de interação remota .NET
Certificados identificar um computador específico, o nome do que reside no nome comum do certificado. No entanto, é fácil alterar o nome de um computador ou use "localhost" em arquivos de configuração do cliente, que cria uma incompatibilidade entre o cliente e o nome comum no certificado de servidor. In the .NET Versão do Framework 1.0, this Mismatch is ignored and the chamar is invoked on the servidor.
Starting with .NET Versão do Framework 1.1, this Mismatch throws the seguinte exceção: " Sistema. Net.WebException: A conexão subjacente estava fechada: Could Not establish Confiar relacionamento with servidor remoto. " Se você não conseguir configurar o cliente remoting para usar o nome comum do certificado, você pode substituir a incompatibilidade usando as seguintes configurações no seu arquivo de configuração do aplicativo do cliente:
<system.net>
<settings>
<servicePointManager
checkCertificateName="true"
/>
</settings>
</system.net>
Para tornar seu cliente ignore a incompatibilidade de nome de certificado programaticamente, o cliente deve criar uma instância de uma classe que implementa a interface https://msdn.microsoft.com/pt-br/library/k8z4ffe4(v=vs.85) ICertificatePolicy e implementa o CheckValidationResult para retornar true se o valor certificateProblem é 0x800c010f. You Must then the with the registrar Sistema. Net.ServicePointManager by passing the to the https://msdn.microsoft.com/pt-br/library/ebw7xd2t(v=vs.85) ServicePointManager.CertificatePolicy. The seguinte Código is a implementação Basic:
Public Class MyPolicy Implements ICertificatePolicy
Public Function CheckValidationResult(srvPoint As ServicePoint, certificate As X509Certificate, request As WebRequest, certificateProblem As Integer) As Boolean
' Check for policy common name mismatch.
If certificateProblem = 0 Or certificateProblem = &H800b010f Then
Return True
Else
Return False
EndIf
End Function
End Class
public class MyPolicy : ICertificatePolicy {
public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) {
// Check for policy common name mismatch.
if (certificateProblem == 0 || certificateProblem == 0x800b010f)
return true;
else
return false;
}
}
The seguinte Código Registers an instância of the acima classe with the System.Net ServicePointManager:
System.Net.ServicePointManager.CertificatePolicy = New MyPolicy()
System.Net.ServicePointManager.CertificatePolicy = new MyPolicy();
Autenticação em aplicativos do sistema de interação remota do IIS-hospedado
A seguinte tabela descreve a configuração Configurações que habilitar certos tipos de comportamento autenticação no arquitetura de comunicação remota do.NET quando que hospeda o serviço no Serviços de Informações da Internet (IIS).
O comportamento desejado |
As definições de configuração |
Comentários |
---|---|---|
O servidor autentica o cliente em cada chamada usando as credenciais padrão clientes. |
On the servidor, Selecionar Integrated Windows Authentication and Clear Acessar Anonymous in IIS. No cliente, defina como useDefaultCredentialstrue. |
Este é o comportamento padrão no of.NET versão 1.0 do Framework quando useDefaultCredentialstrue. Esse comportamento é suportado no of.NET Framework versão 1.1 se useAuthenticatedConnectionSharing também for definido como false. |
O servidor autentica o cliente uma vez usando as credenciais padrão clientes; chamadas subseqüentes deste cliente usar a conexão autenticada anteriormente. |
On the servidor, Selecionar Integrated Windows Authentication and Clear Acessar Anonymous in IIS. No cliente, defina como useDefaultCredentials true. |
This Comportamento is com suporte in.NET only estrutura versão 1.1 or Later. |
The cliente once Using the servidor authenticates Personalizar or credenciais EXPLICIT cliente; chamadas subseqüentes deste cliente usar a conexão autenticada anteriormente. |
On the servidor, Selecionar Integrated Windows Authentication and Clear Acessar Anonymous in IIS. On the client, either set the credentials to an ICredentials implementation, or set the username, password, and domainto explicit values. In either case, you must also set unsafeAuthenticatedConnectionSharing to trueand provide a connectionGroupNamevalue that maps to only one authenticated user. |
This Comportamento is com suporte in.NET only estrutura versão 1.1 or Later. |
Consulte também
Conceitos
Configuração de aplicativos remoto
Exemplo do Sistema de Interação Remota: Hosting in Information Internet Serviços (IIS)