Document Type Declaration (DTD) is prohibited in this XML

I have a WCF service and a Android app that I am passing data back and forth using JSON. I had everything working locally. When I published to the server, I now get this error whenever I try to read in the JSON in the android app. I found several suggestions for using prohibit on a XmlReader, but I'm not using a XmlReader. Here is the code that generates the JSON (which I cannot get to format properly in this forum):

Public Function GetJson(ByVal dt As DataTable) As String

Dim serializer As New System.Web.Script.Serialization.JavaScriptSerializer()

Dim rows As New List(Of Dictionary(Of String, Object))()

Dim row As Dictionary(Of String, Object) = Nothing

For Each dr As DataRow In dt.Rows

row = New Dictionary(Of String, Object)()

For Each dc As DataColumn In dt.Columns

row.Add(dc.ColumnName.Trim(), dr(dc))

Next

rows.Add(row)

Next

Return serializer.Serialize(rows)

End Function

Is there anything I can do on either end to prevent this error? I thought a DTD was a <!DOCTYPE, but that is not even in my JSON. Which by the way is this:[{"fldID":1,"fldGroupID":1,"FirstName":"John","LastName":"Smith"}]

Thanks for any help you can offer.

Posts

  • After looking into this further, it doesn't matter what I pass I get the error. I could pass a single string and get the error. When I had it working I was using a console app for the client. Now I am using an android app. Any ideas? Here is the full error:

    {System.Xml.XmlException: Document Type Declaration (DTD) is prohibited in this XML. Line 7, position 10.
    at Mono.Xml2.XmlTextReader.ReadDoctypeDecl () [0x00000] in :0
    at Mono.Xml2.XmlTextReader.ReadDeclaration () [0x00000] in :0
    at Mono.Xml2.XmlTextReader.ReadContent () [0x00000] in :0
    at Mono.Xml2.XmlTextReader.Read () [0x00000] in :0
    at System.Xml.XmlTextReader.Read () [0x00000] in :0
    at System.Xml.XmlSimpleDictionaryReader.Read () [0x00000] in :0
    at System.Xml.XmlReader.MoveToContent () [0x00000] in :0
    at System.ServiceModel.Channels.XmlReaderMessage.ReadEnvelopeStart () [0x00000] in :0
    at System.ServiceModel.Channels.XmlReaderMessage..ctor (System.ServiceModel.Channels.MessageVersion version, System.Xml.XmlDictionaryReader reader, Int32 maxSizeOfHeaders) [0x00000] in :0
    at System.ServiceModel.Channels.Message.CreateMessage (System.Xml.XmlDictionaryReader envelopeReader, Int32 maxSizeOfHeaders, System.ServiceModel.Channels.MessageVersion version) [0x00000] in :0
    at System.ServiceModel.Channels.TextMessageEncoder.ReadMessage (System.IO.Stream stream, Int32 maxSizeOfHeaders, System.String contentType) [0x00000] in :0
    at System.ServiceModel.Channels.HttpRequestChannel.GotResponse (IAsyncResult result) [0x00000] in :0 } System.Xml.XmlException

  • Please disregard. I had a typo in the url I was trying to connect to. Wow, simple mistake burned a lot of time.

Sign In or Register to comment.