响应消息的内容类型 application/xml;charset=utf-8 与绑定的内容类型不匹配 (text/xml;charset=utf-8)

2024-06-19

我尝试使用独立应用程序使用 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&#xd;
    at org.apache.axis2.engine.DispatchPhase.checkPostConditions(DispatchPhase.java:89)&#xd;
    at org.apache.axis2.engine.Phase.invoke(Phase.java:333)&#xd;
    at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:264)&#xd;
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:163)&#xd;
    at org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:136)&#xd;
    at org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(RESTUtil.java:130)&#xd;
    at org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest(AxisServlet.java:829)&#xd;
    at org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:255)&#xd;
    at com.rm.janus.webservice.GroupCallServlet.doGet(GroupCallServlet.java:33)&#xd;
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)&#xd;
    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:\Users\s\Documents\Visual Studio 2012\Projects\G2TestApp\InetgrisG2TestApp\Service References\G2ServiceReference\Reference.cs:line 2981
   at InetgrisG2TestApp.G2ServiceReference.G2WebServicePortTypeClient.getStudentData(ServiceRequest serviceReq) in c:\Users\s\Documents\Visual Studio 2012\Projects\G2TestApp\G2TestApp\Service References\G2ServiceReference\Reference.cs:line 2987
   at InetgrisG2TestApp.Program.Main(String[] args) in c:\Users\s\Documents\Visual Studio 2012\Projects\G2TestApp\G2TestApp\Program.cs:line 57}

您的 WCF 服务可能返回 HTML。在这种情况下,您需要在服务端设置绑定以返回 XML。然而,这不太可能:如果is如果是这种情况,请告诉我,我将进行更多详细信息的编辑。

更可能的原因是您的服务抛出错误,返回 HTML 错误页面。你可以看一下这篇博文 http://noamlewis.wordpress.com/2012/12/03/custom-error-pages-and-wcf-exceptions-in-iis-and-case-of-bad-ui/如果你想要详细信息。

tl;dr:错误页面有几种可能的配置。如果您在 IIS 上托管,则需要删除<httpErrors>WCF 服务的部分web.config文件。如果没有,请提供您的服务托管方案的详细信息,我可以进行编辑以匹配它们。

EDIT:

查看您的编辑后,您可以看到返回的完整错误。 Apache 无法判断您要调用哪个服务,因此会抛出错误。一旦您拥有正确的端点,该服务就会正常工作——您被指向了错误的位置。不幸的是,我无法从现有信息中得知right位置是,但是您的操作(当前null!) 或 URL 不正确。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

响应消息的内容类型 application/xml;charset=utf-8 与绑定的内容类型不匹配 (text/xml;charset=utf-8) 的相关文章

  • c和java语言中的换行符

    现在行分隔符取决于系统 但在 C 程序中我使用 n 作为行分隔符 无论我在 Windows 还是 Linux 中运行它都可以正常工作 为什么 在java中 我们必须使用 n 因为它与系统相关 那么为什么我们在c中使用 n 作为新行 而不管我
  • 使用 Unity 在构造函数中使用属性依赖注入

    好的 我在基类中定义了一个依赖属性 我尝试在其派生类的构造函数内部使用它 但这不起作用 该属性显示为 null Unity 在使用 container Resolve 解析实例后解析依赖属性 我的另一种选择是将 IUnityContaine
  • 使用Physics.Raycast 和Physics2D.Raycast 检测对象上的点击

    我的场景中有一个空的游戏对象 带有 2D 组件盒碰撞器 我将脚本附加到该游戏对象 void OnMouseDown Debug Log clic 但是当我点击我的游戏对象时 没有任何效果 你有什么想法 如何检测我的盒子碰撞器上的点击 使用光
  • Unix网络编程澄清

    我正在翻阅这本经典书籍Unix网络编程 https rads stackoverflow com amzn click com 0139498761 当我偶然发现这个程序时 第 6 8 节 第 179 180 页 include unp h
  • 为 Visual Studio 2013 编译 Tesseract

    我正在尝试使用tesseract在 Visual Studio 2013 中 我在链接器 gt 输入 不是 libtesseract302 static lib 中使用 libtesseract302 lib 一切都正常 并且已编译并运行
  • 如何访问另一个窗体上的ListView控件

    当单击与 ListView 所在表单不同的表单中的按钮时 我试图填充 ListView 我在 Form1 中创建了一个方法以在 Form2 中使用 并将参数传递给 Form1 中的方法 然后填充 ListView 当我调试时 我得到了传递的
  • 存储来自其他程序的事件

    我想将其他应用程序的事件存储在我自己的应用程序中 事件示例 打开 最小化 Word 或打开文件时 这样的事可能吗 运行程序 http msdn microsoft com en us library ms813609 aspx and 打开
  • 用于检查项目文件中的项目变量和引用路径的 api

    我正在研究一个 net application VS2010 与 x 没有 解和变量号这些解决方案中的项目数量 我需要检查项目属性 特定于一定数量的项目 是否同质 并且检查 验证构建期间的参考路径 有没有一个API是这样的吗 如果没有 我该
  • C# Dns.GetHostEntry 不返回连接到 WiFi 的移动设备的名称

    我有一个 C 中的 Windows 窗体应用程序 我试图获取列表中所有客户端的主机名 下面给出的是 ra00l 来自此链接的代码示例 GetHostEntry 非常慢 https stackoverflow com questions 99
  • 无法在 Windows 运行时组件库的 UserControl 中创建依赖项属性

    我想在用户控件内创建数据可绑定属性 这个用户控件包含一个 Windows 运行时组件 项目 我使用下面的代码来创建属性 public MyItem CurrentItem get return MyItem GetValue Current
  • 获取 WPF 控件的所有附加事件处理程序

    我正在开发一个应用程序 在其中动态分配按钮的事件 现在的问题是 我希望获取按钮单击事件的所有事件 因为我希望删除以前的处理程序 我尝试将事件处理程序设置为 null 如下所示 Button Click null 但是我收到了一个无法分配 n
  • 在一个字节中存储 4 个不同的值

    我有一个任务要做 但我不知道从哪里开始 我不期待也绝对不想要代码中的答案 我想要一些关于该怎么做的指导 因为我感到有点失落 将变量打包和解包到一个字节中 您需要在一个字节中存储 4 个不同的值 这些值为 NAME RANGE BITS en
  • 如何在 Blackberry Cascades 中显示具有特定号码的电话板

    我正在使用带有 C QT 和 QML 的 Blackberry Cascades 10 Beta 3 SDK 以及 Blackberry 10 Dev Alpha Simulator 和 QNX Momentics IDE 并且我正在尝试实
  • std::async 与重载函数

    可能的重复 std bind 重载解析 https stackoverflow com questions 4159487 stdbind overload resolution 考虑以下 C 示例 class A public int f
  • 如何对 Web Api 操作进行后调用?

    我创建了一个 Web API 操作 如下所示 HttpPost public void Load string siteName string providerName UserDetails userDetails implementat
  • gcc 的配置选项如何确定默认枚举大小(短或非短)?

    我尝试了一些 gcc 编译器来查看默认枚举大小是否很短 至少一个字节 强制使用 fshort enums 或无短 至少 4 个字节 强制使用 fno short enums user host echo Static assert 4 si
  • 用于 C# 的 TripleDES IV?

    所以当我说这样的话 TripleDES tripledes TripleDES Create Rfc2898DeriveBytes pdb new Rfc2898DeriveBytes password plain tripledes Ke
  • 如何在按钮单击时模拟按键 - Unity

    我对 Unity 中的脚本编写非常陌生 我正在尝试创建一个按钮 一旦单击它就需要模拟按下 F 键 要拾取一个项目 这是我当前的代码 在编写此代码之前我浏览了所有统一论坛 但找不到任何有效的东西 Code using System Colle
  • 如何使用 Word Automation 获取页面范围

    如何使用办公自动化找到 Microsoft Word 中第 n 页的范围 似乎没有 getPageRange n 函数 并且不清楚它们是如何划分的 这就是您从 VBA 执行此操作的方法 转换为 Matlab COM 调用应该相当简单 Pub
  • 在客户端系统中安装后桌面应用程序无法打开

    我目前正在使用 Visual Studio 2017 和 4 6 1 net 框架 我为桌面应用程序创建了安装文件 安装程序在我的系统中完美安装并运行 问题是安装程序在其他计算机上成功安装 但应用程序无法打开 edit 在客户端系统中下载了

随机推荐