2011-09-13 5 views
2

J'ai accompagné mon WCF en utilisant IIS 7.0, l'URL est:Ajouter une référence de service n'a pas

https://example.com/CustPortal/CustomerService.svc 

quand j'ajouter une référence de service dans VS2008, a obtenu cette erreur:

The document at the url https://example.com/CustPortal/CustomerService.svc was not recognized as a known document type. 
The error message from each known type may help you fix the problem: 
- Report from 'DISCO Document' is 'There was an error downloading 'https://el-cust-port01/CustPortal/CustomerService.svc?disco'.'. 
    - Unable to connect to the remote server 
    - No connection could be made because the target machine actively refused it 59.37.71.86:443 
- Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'. 
- Report from 'https://193.91.152.191/CustPortal/CustomerService.svc' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'. 
- Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'. 
Metadata contains a reference that cannot be resolved: 'https://193.91.152.191/CustPortal/CustomerService.svc'. 
Metadata contains a reference that cannot be resolved: 'https://193.91.152.191/CustPortal/CustomerService.svc'. 
If the service is defined in the current solution, try building the solution and adding the service reference again. 

Mon web.config est-

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="metadataBehavior"> 
      <serviceMetadata httpsGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
      <serviceCredentials> 
      <serviceCertificate storeName="My" x509FindType="FindBySubjectName" findValue="TESTCERT" storeLocation="LocalMachine"/> 
      </serviceCredentials> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="metadataBehavior" name="EV.Services.CustomerService"> 
     <endpoint binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfig" contract="EV.Contracts.ICustomer" /> 
     </service> 
    </services> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="wsHttpBindingConfig"> 
      <security mode="Transport"> 
      <transport clientCredentialType="None"/> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    </system.serviceModel> 

Répondre

4

Je pense qu'il vous manque également un point de terminaison Metadata Excahnge (mex). Essayez d'ajouter:

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 

sous votre point de terminaison existant. Vous devriez être en mesure d'ouvrir un navigateur Web pour:

https://193.91.152.191/CustPortal/CustomerService.svc?wsdl

et voir le fichier WSDL réel affiché.

+0

salut rallye, vous êtes super-homme, ça marche pour moi utilisé votre code. mais j'ai un autre problème lorsque j'appelle la méthode: Impossible d'établir une relation d'approbation pour le canal sécurisé SSL/TLS avec l'autorité '193.91.152.191'. – GBK

+1

j'ai cherché et obtenu une solution en utilisant le code ci-dessous: 'ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback (OnValidationCallback),' ' bool public static OnValidationCallback (expéditeur d'objet, X509Certificate cert, chaîne X509Chain, erreurs SslPolicyErrors) { return true; } ' – GBK

+0

Vous pouvez trouver une liste de tous les changements nécessaires pour faire fonctionner un service wcf sur https ici. On dirait que c'était le seul qui vous manquait. https://www.codeproject.com/Articles/36705/simple-steps-to-enable-HTTPS-on-WCF-WsHttp-bindi –

0

Hébergez-vous cela à la maison? L'erreur dit essentiellement que vous ne pouvez pas atteindre l'adresse IP, ce que je peux. Cela peut être un routeur ne supportant pas "nat loopback", donc vous ne pouvez pas accéder à votre adresse IP externe à l'intérieur de votre réseau. Essayez d'ajouter la référence par son adresse IP locale.

+0

non, c'est une adresse IP publique, vous pouvez accéder via https: //193.91.152.191/CustPortal/CustomerService.svc?wsdl, mais impossible d'ajouter une référence de service dans vs2008. – GBK

0

ajouter le nom d'hôte et l'adresse IP du webservice dans le fichier hosts de votre PC local du serveur (C: \ Windows \ System32 \ drivers \ etc \ hosts)

Questions connexes