HttpWebRequest Problem


  • Hello,

    I'm trying to post an xml file and read the response. Everything runs fine on my development computer in localhost mode, but when I run it on the server I get the following message. I've tried looking it up all over the internet with no success. Can anyone help? 

    First the code:


    "C:\JMS\JMS" & OrderNo & LastPU & ".xml")




    Public Sub SendJCX(ByVal jms As String)


    Dim s As Socket = Nothing


    Dim port As Integer = 80


    Dim hostEntry As IPHostEntry = Nothing

    hostEntry = Dns.GetHostEntry(



    ' Loop through the AddressList to obtain the supported AddressFamily. This is to avoid


    ' an exception that occurs when the host host IP Address is not compatible with the address family


    ' (typical in the IPv6 case).


    Dim address As IPAddress


    For Each address In hostEntry.AddressList


    Dim endPoint As New IPEndPoint(address, port)


    Dim tempSocket As New Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)



    If tempSocket.Connected Then

    s = tempSocket


    Exit For


    End If




    ' s is the address we need!

    s.ReceiveTimeout = 30 * 1000


    'Set up variables and String to write to the server.


    Dim ascii As Encoding = Encoding.ASCII


    Dim passcode As Byte() = System.Text.Encoding.UTF8.GetBytes("ntf:ntf")


    Dim passcode1 As String = ToBase64(passcode)


    Dim userpass As New NetworkCredential

    userpass.UserName =


    userpass.Password = passcode1


    Dim bytesSent As [Byte]() = ascii.GetBytes(jms)


    Dim bytesReceived(255) As [Byte]


    Dim request1 As HttpWebRequest = WebRequest.Create("http://jms.carrustechnologies.com/ntfxml")

    request1.ContentLength = bytesSent.Length

    request1.ContentType =


    request1.Credentials = userpass

    request1.Method =



    Dim request2 As Stream = request1.GetRequestStream()

    request2.Write(bytesSent, 0, bytesSent.Length)


    ' Receive the server home page content.


    ' Read the first 256 bytes.


    Dim response As HttpWebResponse = CType(request1.GetResponse(), HttpWebResponse)


    Dim receiveStream As Stream = response.GetResponseStream()


    Dim readStream As New StreamReader(receiveStream, Encoding.UTF8)


    Dim replyxml As New XmlDocument



    Dim replyNode As XmlNodeList = replyxml.GetElementsByTagName("header")


    Dim replyElement As XmlElement = replyNode.Item(0)


    Dim errStatus As String = replyElement.GetAttribute("errcode")


    If errStatus = "success" Then

    ErrorFlag =




    ErrorFlag =



    End If


    End Sub

    Now the error:


    Server Error in '/PM' Application.

    Could not find file 'c:\windows\system32\inetsrv\ExceptionMessageGuideline.dtd'.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\ExceptionMessageGuideline.dtd'.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\ExceptionMessageGuideline.dtd'.]
       System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +305
       System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +1162
       System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) +64
       System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) +77
       System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) +54
       System.Xml.XmlTextReaderImpl.OpenStream(Uri uri) +34
       System.Xml.XmlTextReaderImpl.DtdParserProxy_PushExternalSubset(String systemId, String publicId) +194
       System.Xml.DtdParserProxy.System.Xml.IDtdParserAdapter.PushExternalSubset(String systemId, String publicId) +16
       System.Xml.DtdParser.ParseExternalSubset() +21
       System.Xml.DtdParser.ParseInDocumentDtd(Boolean saveInternalSubset) +4016925
       System.Xml.DtdParser.Parse(Boolean saveInternalSubset) +54
       System.Xml.DtdParserProxy.Parse(Boolean saveInternalSubset) +31
       System.Xml.XmlTextReaderImpl.ParseDoctypeDecl() +254
       System.Xml.XmlTextReaderImpl.ParseDocumentContent() +451
       System.Xml.XmlTextReaderImpl.Read() +151
       System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) +48
       System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +129
       System.Xml.XmlDocument.Load(XmlReader reader) +108
       System.Xml.XmlDocument.Load(TextReader txtReader) +91
       Confirm.SendJCX(String jms) +508
       Confirm.SendJMS(Int32 OrderNo) +723
       Confirm.OrdButton_Click(Object sender, EventArgs e) +3151
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

    Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
    Monday, July 06, 2009 4:51 PM

All replies

  • Before you load your XML File, try setting the XMLResolver property = nothing.

    Dim replyxml As New XmlDocument
    replyxml.XmlResolver = Nothing

    or load your DTD file onto the server in the path specified

    Joshua Bylotas

    • Proposed as answer by Joshua Bylotas Monday, October 05, 2009 12:04 AM
    Saturday, August 01, 2009 6:17 PM