我在我的本地IIS服务器上运行了一个WCF服务.我已将其添加为C#Website Project的服务引用,并且它会添加正常并自动生成代理类.
但是,当我尝试调用任何服务合同时,我收到以下错误:
描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.
异常详细信息: System.ServiceModel.ProtocolException:内容类型text/html; 所述响应消息不匹配的结合(;字符集= UTF-8应用/肥皂+ XML)的内容类型的字符集= UTF-8.如果使用自定义编码器,请确保正确实现IsContentTypeSupported方法.响应的前1024个字节是:'function bredir(d,u,r,v,c){var w,h,wd,hd,bi; var b = false; var p = false; var s = [[ 300250,假],[250250,假],[240400,假],[336280,假],[180150,假],[468,60,假],[234,60,假],[88,31,假],[120,90,假],[120,60,假],[120240,假],[125125,假],[728,90,假],[160600,假],[120600,假] [300600,假],[300125,假],[530300,假],[190200,假],[470250,假],[720300,真],[500350,真],[550480,真]]; if(typeof(window.innerHeight)=='number'){h = window.innerHeight; w = window.innerWidth;} else if(typeof(document.body.offsetHeight)=='number'){h = document. body.offsetHeight; w = document.body.offsetWidth;} for(var i = 0; i
我还有一个控制台应用程序,它也与WCF服务通信,控制台应用程序能够调用方法,而不会出现此错误.
以下是我的配置文件的摘录.
WCF服务Web.Config:
<system.serviceModel>
<services>
<service name="ScraperService" behaviorConfiguration="ScraperServiceBehavior">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IScraperService"
contract="IScraperService" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://example.com" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IScraperService"
bypassProxyOnLocal="false" transactionFlow="false" …Run Code Online (Sandbox Code Playgroud) 我尝试使用独立应用程序使用WCF Web服务.我能够使用Internet Explorer查看此服务,也可以在Visual Studio服务引用中查看.
这是我得到的错误
The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8).
Run Code Online (Sandbox Code Playgroud)
如何更改此选项以使用正确的内容类型?
这是我的配置文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="G2WebServiceSoap11Binding" />
</basicHttpBinding>
<customBinding>
<binding name="G2WebServiceSoap12Binding">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://XXX.XX.XX.XX:XX/janus/services/G2WebService.G2WebServiceHttpSoap11Endpoint/"
binding="basicHttpBinding" bindingConfiguration="G2WebServiceSoap11Binding"
contract="G2ServiceReference.G2WebServicePortType"
name="G2WebServiceHttpSoap11Endpoint" />
<endpoint address="http://XXX.XX.XX.XX:XX/janus/services/G2WebService.G2WebServiceHttpSoap12Endpoint/"
binding="customBinding" bindingConfiguration="G2WebServiceSoap12Binding"
contract="G2ServiceReference.G2WebServicePortType"
name="G2WebServiceHttpSoap12Endpoint" />
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
这是堆栈
{System.ServiceModel.ProtocolException: The content type application/xml;charset=utf-8 of …Run Code Online (Sandbox Code Playgroud) 我得到"不支持给定路径的格式." 当我只是尝试从我的SDL Tridion 2011 SP1下载多媒体图像时,下面是我得到的路径,不知道"N:"等即将到来.
D:\ delete\Images\N:\ dmc.FlipMedia.Clients.TestCMS\2009_WorkInProgress\creatives\05_May\16岁以下儿童免费访问英国\ assets_graphics\jpg\Kids_go_free_385x306.jpg
以下是代码:
public static void GetBinaryFromMultimediaComponent(string tcm, CoreServiceClient client, StreamDownloadServiceClient streamDownloadClient)
{
ComponentData multimediaComponent = client.ReadItem(tcm) as ComponentData;
// Generate you own file name, and file location
string file = "D:\\delete\\Images\\" + multimediaComponent.BinaryContent.Filename;//Here I am getting above path
// Write out the existing file from Tridion
FileStream fs = File.Create(file);//Here getting the exception
byte[] binaryContent = null;
if (multimediaComponent.BinaryContent.FileSize != -1)
{
Stream tempStream = streamDownloadClient.DownloadBinaryContent(tcm);
var memoryStream = new MemoryStream();
tempStream.CopyTo(memoryStream); …Run Code Online (Sandbox Code Playgroud) 我正在维护一个使用大量 WCF 服务的大型项目,当某些用户登录该网站时,他们会收到此错误
The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: ' '.
Run Code Online (Sandbox Code Playgroud)
我不知道这可能是什么原因,也不知道在哪里可以解决它。有任何想法吗?