none
The remote server returned an error: (500) Internal Server Error. RRS feed

  • Question

  • Am working on Windows Application 

    I can request and response with the code and connection i had , My problem is if no error on response am getting the succesfull response but if any error its not showing the exact error just throwing the The remote server returned an error: (500) Internal Server Error.

    My code below Please help me

       Private Function BuildMessageRequest(ByVal strUserName As String, ByVal strUserPwd As String, ByVal chrFileType As Char) As String
          'TaxLogInfo("", "Forming the Request Message for the file started")
          Dim strMessage As New StringBuilder()
          Dim strUserID As String, strPassword As String, strSubmissionType As String, strReferenceID As String

          'strUserID = ConfigurationSettings.AppSettings("UserID").ToString()
          'strPassword = ConfigurationSettings.AppSettings("Password").ToString()
          'strSubmissionType = ConfigurationSettings.AppSettings("SubmissionType").ToString()

          strUserID = strUserName
          strPassword = strUserPwd
          strSubmissionType = "TC109XML"

          'Forming ReferenceID eg: UTDYYYYMMDDTHHMMSS
          '                    WHERE,
          '                    UT  - Utah state 
          '                    D - DATE DEMARKER
          '                    YYYYMMDD -  YEARMONTHDATE
          '                    T  - TIME DEMARKER
          '                    HHMMSS - HOURMINSECOND


          strReferenceID = "UTD" & DateTime.Now.ToString("yyyyMMdd") & "T" & DateTime.Now.ToString("HHmmss")

          strMessage.Append("<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:fas=""http://www.fastenterprises.com"">")
          strMessage.Append("<soapenv:Header>")
          strMessage.Append("<fas:MFETHeader>")
          strMessage.Append("<fas:User>" & strUserID & "</fas:User>")
          strMessage.Append("<fas:Password>" & strPassword & "</fas:Password>")
          If chrFileType = "P" Then
            strMessage.Append("<fas:Environment>P</fas:Environment>")
          Else
            strMessage.Append("<fas:Environment>T</fas:Environment>")
          End If
          strMessage.Append("</fas:MFETHeader>")
          strMessage.Append("</soapenv:Header>")
          strMessage.Append("<soapenv:Body>")
          strMessage.Append("<fas:SubmissionType>" & strSubmissionType & "</fas:SubmissionType>")
          strMessage.Append("<fas:ReferenceId>" & strReferenceID & "</fas:ReferenceId>")
          strMessage.Append("<fas:File>" & Me.FileData & "</fas:File>")
          strMessage.Append("</soapenv:Body>")
          strMessage.Append("</soapenv:Envelope>")


          Return strMessage.ToString()
        End Function

        'Invoking Web Method
        Public Sub SubmitFile(Optional ByVal chrFileType As Char = "T")
          Try
            ServicePointManager.CertificatePolicy = New TestingCertificatePolicy()
            'Dim hwr As HttpWebRequest = DirectCast(WebRequest.Create(ConfigurationSettings.AppSettings("URL").ToString()), HttpWebRequest)
            Dim hwr As HttpWebRequest

            If chrFileType = "T" Then 'Test Environment 
              hwr = DirectCast(WebRequest.Create("https://tapstaging.tax.utah.gov/efile/mfet/wsdl/"), HttpWebRequest)
            Else ' Production Environment
              hwr = DirectCast(WebRequest.Create("https://tap.tax.utah.gov/efile/mfet/wsdl/"), HttpWebRequest)
            End If
            hwr.Headers.Add("SOAPAction", "http://www.fastenterprises.com/MFET/NewSubmission")
            hwr.ContentType = "text/xml; charset=""utf-8"""
            hwr.Timeout = 10000000
            hwr.Method = "POST"
            Using stm As Stream = hwr.GetRequestStream()
              Using stmw As New StreamWriter(stm)
                stmw.Write(Me.ReqMsg)
              End Using
            End Using

            Dim hwrsp As HttpWebResponse = DirectCast(hwr.GetResponse(), HttpWebResponse)

    'After the Above response  if no error it will pass to next thread but if any error it will directly throw exception 500 internal error

            Dim objSread As New StreamReader(hwrsp.GetResponseStream())
            Me.ResMsg = objSread.ReadToEnd().ToString()
            DisplayErrorMsg(Me.ResMsg)
            objSread.Close()
            hwrsp.Close()
          Catch ex As Exception
            Throw ex
          End Try
        End Sub

    Monday, December 22, 2014 3:56 PM

Answers

  • I'd try them over here.

    http://forums.asp.net/

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Tuesday, December 23, 2014 1:22 AM
    Moderator