D'erreur lorsque vous essayez de consommer service WCF retour fichier
Un de mes méthodes retourne byte[], d'un fichier. Toutes les autres méthodes retournent une chaîne d'objets ou d'objets personnalisés
Je peux afficher le WSDL via un navigateur et que j'ai utilisé WCfExtras, je peux même voir la documentation.
Dans mon appli de test, C# une application web, j'ajoute la référence à mon service, hébergé sur un serveur de test. J'obtiens une erreur en tant que telle:
The document was understood, but it could not be processed.
- The WSDL document contains links that could not be resolved.
- There was an error downloading ...
- Unable to connect to remote server
- No connection could be made because the target machine actively refused it
Content Type application/soap+xml; charset=utf-8 was not supported by service . The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.
C'est mon application.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="TestApp.Properties.Settings.TestDBConnectionString"
connectionString="Data Source=192.168.2.130;Initial Catalog=TestDB;Persist Security Info=True;User ID=sa;Password=xerox"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service behaviorConfiguration="TestApp.Service1Behavior"
name="TestApp.SearchService">
<endpoint address="" behaviorConfiguration="Sample.WsdlSampleEndpointBehavior"
binding="basicHttpBinding" bindingConfiguration="WsHttpMtomBinding" contract="TestApp.ISearchService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/TestApp/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="Sample.WsdlSampleEndpointBehavior">
<wsdlExtensions location="http://localhost:8731/TestApp/Service1/"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="TestApp.Service1Behavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<!-- Declare that we have an extension called WSDL Extras-->
<add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
<bindings>
<basicHttpBinding>
<binding name="WsHttpMtomBinding" messageEncoding="Mtom" transferMode="StreamedResponse" />
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
Des idées sur comment je pourrais résoudre ce problème? Je devrais avoir 2 différentes liaisons, l'une des méthodes de retour non octets[] et Mtom pour la méthode de retour byte[]? Si oui, comment applique-t-on les liaisons par la méthode exposée?
Essayé de courir avec WcfTestClient.exe et c'est l'erreur
rror: Cannot import wsdl:portTypeDetail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporterError: Schema with target namespace 'http://tempuri.org/' could not be found.XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ISearchService']Error: Cannot import wsdl:bindingDetail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ISearchService']XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_ISearchService']Error: Cannot import wsdl:portDetail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_ISearchService']XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='SearchService']/wsdl:port[@name='BasicHttpBinding_ISearchService']Warning: No code was generated.If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or servicesor because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.Warning: If you would like to generate data contracts from schemas make sure to use the /dataContractOnly option.
Vous devez vous connecter pour publier un commentaire.
J'ai le même problème. J'ai été d'hébergement de la wcf sur la distance win2008 serveur IIS. La solution qui a fonctionné pour moi a été de déterminer le nom de l'hôte lors de l'ajout de site web et de ne pas la laisser vide après le réglage de toutes les autres données pour l'hébergement!
Sur l'application cliente, vous avez une référence à la WCFExtras assemblée? L'erreur semble dire que la liaison n'est pas reconnu, ce qui est, je suppose, parce que les extensions introduites par WCFExtras. Essayez d'ajouter la même section extensions à votre client de fichier de configuration dans le serveur de fichier de configuration.
Votre liaison est basicHttpBinding, mais votre configuration de liaison est wsHttpMTOMBinding.
Cela ressemble à une incompatibilité, mais il pourrait être juste le nom que vous avez donné des choses.
Essayer d'ouvrir le fichier de config dans le WCF outil de configuration, cela devrait vous dire (refuser d'ouvrir le fichier), si il y a des incohérences dans votre fichier de configuration.
Espère que cette aide
Shiraz
Cela ne peut pas être une vraie réponse, mais après je l'ai enlevé WCfExtras références à partir de mon application.fichier de configuration et le déploiement de choses semblent fonctionner.
C'est ce que je cherchais, mais ont abandonné pour le moment
WCF Extras
Si quelqu'un a une idée de comment et ce que j'ai mal configuré, veuillez indiquer dans cette colonne.
Merci Beaucoup
La réponse pour moi d'être en mesure d'utiliser le Client Test WCF est de définir l'ensemble singleFile="true" dans la configuration web de ce genre.