c# – 响应消息的内容类型application / xml; charset = utf-8与
发布时间:2020-12-15 03:55:51 所属栏目:百科 来源:网络整理
导读:我试图使用独立应用程序使用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 bind
我试图使用独立应用程序使用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). 如何更改此使用正确的内容类型? 这是我的配置文件 <?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> 这里是堆栈 {System.ServiceModel.ProtocolException: The content type application/xml;charset=utf-8 of the response message does not match the content type of the binding (text/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: '<Exception>org.apache.axis2.AxisFault: The endpoint reference (EPR) for the Operation not found is /janus/services/G2WebService and the WSA Action = null
 at org.apache.axis2.engine.DispatchPhase.checkPostConditions(DispatchPhase.java:89)
 at org.apache.axis2.engine.Phase.invoke(Phase.java:333)
 at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:264)
 at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:163)
 at org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:136)
 at org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(RESTUtil.java:130)
 at org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest(AxisServlet.java:829)
 at org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:255)
 at com.rm.janus.webservice.GroupCallServlet.doGet(GroupCallServlet.java:33)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
 at javax.servlet.http.HttpSer'. ---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error. at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) --- End of inner exception stack trace --- Server stack trace: at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request,HttpWebResponse response,HttpChannelFactory`1 factory,WebException responseException,ChannelBinding channelBinding) at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message,TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message,TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object[] ins,Object[] outs,TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 type) at InetgrisG2TestApp.G2ServiceReference.G2WebServicePortType.getStudentData(getStudentDataRequest request) at InetgrisG2TestApp.G2ServiceReference.G2WebServicePortTypeClient.G2TestApp.G2ServiceReference.G2WebServicePortType.getStudentData(getStudentDataRequest request) in c:UserssDocumentsVisual Studio 2012ProjectsG2TestAppInetgrisG2TestAppService ReferencesG2ServiceReferenceReference.cs:line 2981 at InetgrisG2TestApp.G2ServiceReference.G2WebServicePortTypeClient.getStudentData(ServiceRequest serviceReq) in c:UserssDocumentsVisual Studio 2012ProjectsG2TestAppG2TestAppService ReferencesG2ServiceReferenceReference.cs:line 2987 at InetgrisG2TestApp.Program.Main(String[] args) in c:UserssDocumentsVisual Studio 2012ProjectsG2TestAppG2TestAppProgram.cs:line 57} 解决方法
您的WCF服务可能返回HTML.在这种情况下,您将需要在服务端设置绑定以返回XML.但是,这是不可能的:如果是这样的话,让我知道,我会进行更多的细节编辑.
更可能的原因是您的服务发生错误,这是返回HTML错误页面.你可以看看this blog post如果你想要的细节. TL;博士: 编辑: 看到您的编辑后,您可以看到正在返回的完整错误. Apache无法确定您要调用哪个服务,并且因此导致错误.一旦您拥有正确的端点,该服务就会正常工作 – 您指向错误的位置.不幸的是,从信息中可以看出正确的位置是什么,但您的操作(当前为空!)或URL不正确. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |