prolog异常中不允许的内容 [英] content not allowed in prolog exception

查看:145
本文介绍了prolog异常中不允许的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将xml发送到第三方通过ac #.net应用程序提供给我的基于java的Web服务,我得到 org.xml.sax.SAXParseException:Content is is prolog中不允许错误。

I am trying to send xml to a java-based web service given to me by a third party via a c#.NET application, and I get the org.xml.sax.SAXParseException: Content is not allowed in prolog error.

我已根据模式验证了xml,并且我传递了用于将xml保存到.xml文件的内存流,然后使用十六进制编辑器打开文件确保序言中没有不受欢迎的字符,而且没有。打开时,文件中的第一个字符是

I have verified the xml against the schema, and I passed the memorystream I am using to hold the xml to an .xml file, then opened the file with a hex editor to make sure that there were no undesired characters in the prolog, and there are none. When opened, the first characters in the file are

<?xml version="1.0" encoding="utf-8"?>

我用来将xml数据发送到Web服务的类接受一个字节数组。我认为使用 XmlTextWriter 创建xml到utf-8编码的内存流,然后将流的内容发送到字节数组是最直接的方法。

The class I was given to use to send the xml data to the web service accepts a byte array. I figure that creating the xml using an XmlTextWriter to a utf-8 encoded memorystream, then sending the contents of the stream to a byte array is the most direct method.

我已经做了很多研究并尝试了我能找到的这个问题的所有可能性,但没有任何效果。有人可以帮忙吗?在此先感谢。

I have done a lot of research and tried all the possbilities around this issue that I could find, but nothing works. Could someone please help? Thanks in advance.

顺便说一下,这是Web服务返回给我的部分内容。在SOAP消息的有效负载中, 元素之后的数据应该是这样的,还是像之前的内容一样可读的xml?

By the way, here is a portion of what the web service returns to me. In the payload of the SOAP message, should the data after the element look like that, or be readable xml like the content before it?

Messages:
Message:

Payload: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http:/
/schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema
-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><postSubmissi
on xmlns="http://service.arm.hud.gov/"><submissionHeader><agcHcsId>1</agcHcsId><
agcName>test</agcName><systemName>123</systemName><cmsSubId>123456</cmsSubId><su
bFlag>0</subFlag></submissionHeader><agcType>test</agcType><submissionData>PD94b
WwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48dG5zOlN1Ym1pc3Npb25EYXRhIHhzaTpzY
2hlbWFMb2NhdGlvbj0iaHR0cDovL2dvdi5odWQuYXJtL2FybV9kYXRhYmFnXzNfMS54c2QiIHhtbG5zO
nhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxT......etc............................
</submissionData></postSubmission></soap:Body></soap:Envelope>

这里有xml数据以提高可读性:

Here the xml data for better readability:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http:/
    /schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema
    -instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <postSubmissi on xmlns="http://service.arm.hud.gov/">
            <submissionHeader>
                <agcHcsId>1</agcHcsId>
                <agcName>test</agcName>
                <systemName>123</systemName>
                <cmsSubId>123456</cmsSubId>
                <subFlag>0</subFlag>
            </submissionHeader>
            <agcType>test</agcType>
            <submissionData>PD94b
                WwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48dG5zOlN1Ym1pc3Npb25EYXRhIHhzaTpzY
                2hlbWFMb2NhdGlvbj0iaHR0cDovL2dvdi5odWQuYXJtL2FybV9kYXRhYmFnXzNfMS54c2QiIHhtbG5zO
                nhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxT......etc............................
            </submissionData>
        </postSubmission>
    </soap:Body>
</soap:Envelope>


推荐答案

我能够通过删除来解决问题UTF编码。听起来像在我们的两种情况下,文本实际上不是UTF-8编码。

I was able to get rid of the problem by removing the UTF encoding. Sounds like in both of our cases, the text wasn't actually UTF-8 encoded.

这篇关于prolog异常中不允许的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆