J'ai recherché et recherché et je ne trouve pas de solution. Il semble qu'il serait relativement courant de lancer ce service ... WCF REST sur https. Lorsque j'ajoute la référence de service, toutes les classes proxy sont correctes et je peux créer les objets définis dans le service, appeler les services, etc. Cependant, je ne peux pas créer un client configuré avec les classes client du proxy. Je dois explicitement créer les liaisons, les comportements et les points de terminaison et les ajouter au client. Par exemple, ce que je devrais être en mesure de le faire, en fonction de l'ensemble de mes recherches est:Ajout d'une référence de service à un service WCF avec webHttpBinding et le mode de sécurité Les résultats de transport dans un fichier de configuration incorrect
ServiceClient = new ServiceClient();
Et être en cours d'exécution et hors. Cependant, ce que je dois faire est:
WebHttpBinding serviceBinding = new WebHttpBinding(WebHttpSecurityMode.Transport);
serviceBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
EndpointAddress endPointAddress
= new EndpointAddress(<endpointaddress>);
// Create Service Client
ServiceClient = new ServiceClient(serviceBinding, endPointAddress);
// Add Web Behavior to the EndPoint
WebHttpBehavior webHttpBehavior = new WebHttpBehavior();
ServiceClient.Endpoint.Behaviors.Add(webHttpBehavior);
// Set up the request to POST with a wrapped request
WebInvokeAttribute postAttribute = new WebInvokeAttribute();
postAttribute.Method = "POST";
postAttribute.BodyStyle = WebMessageBodyStyle.WrappedRequest;
ServiceClient.Endpoint.Contract.Operations.Find(<operationname>).Behaviors.Add(postAttribute);
Pour imiter la configuration du service:
<behaviors>
<endpointBehaviors>
<behavior name="AspNetAjaxBehaviorXml">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="AuthenticationServicesBehavior">
<serviceMetadata httpsGetEnabled="true" policyVersion="Policy15" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="LoggingServicesBehavior">
<serviceMetadata httpsGetEnabled="true" policyVersion="Policy15" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="True" />
<bindings>
<webHttpBinding>
<binding name="WebSslBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="AuthenticationServicesBehavior"
name="AuthenticationServices">
<endpoint address="authenticate" behaviorConfiguration="AspNetAjaxBehaviorXml"
binding="webHttpBinding" bindingConfiguration="WebSslBinding"
name="AuthenticationEndPoint" bindingNamespace="<mynamespace>"
contract="IService" />
</service>
Le "Ajouter un service de référence" me donne ceci:
<bindings>
<customBinding>
<binding name="AuthenticationEndPoint">
<!-- WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'EchoAppsServices': -->
<!-- <wsdl:binding name='AuthenticationEndPoint'> -->
<!-- <sp:HttpsToken xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">..</sp:HttpsToken> -->
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
</binding>
</customBinding>
</bindings>
<client>
<endpoint binding="customBinding" bindingConfiguration="AuthenticationEndPoint"
contract="AuthenticationService"
name="AuthenticationEndPoint" />
</client>
Je crois que mon incapacité à créer un client par défaut qui fonctionne hors de la boîte est liée au problème avec WsdlImporte r. Je reçois une erreur similaire lorsque j'utilise svcutil:
Warning: The following Policy Assertions were not Imported:
XPath://wsdl:definitions[@targetNamespace='<mynamespace>']/wsdl:binding[@na
me='AuthenticationEndPoint']
Assertions:
<sp:HttpsToken xmlns:sp='http://schemas.xmlsoap.org/ws/2005/07/securitypolic
y'>..</sp:HttpsToken>
Je suis sûr qu'il a quelque chose à voir avec mon auto-signé cert, mais je ne peux pas makecert me donner un cert fonctionnant avec un CA qui doesn Ne provoquez pas mon IIS.
détails Environnement: VS2008 XP 64bit .NET 3.5 IIS6
Merci à l'avance pour toute aide ...
marc_s - Merci pour votre avis. C'est une sorte de faute de frappe, j'ai fait des allers-retours en essayant de faire fonctionner ça et vous avez attrapé quelque chose qui était entre les itérations. Il est censé être l'authentification Windows. Je pensais que mon problème était lié au mode d'authentification, mais ce n'était pas le cas. La raison pour laquelle j'essaie d'éviter tout type de paramètres manuels est parce que je veux pouvoir mettre à jour du WSDL mais je ne peux pas maintenant en raison des erreurs ci-dessus. – GunnerL3510