Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please advice to correct the VB Code.

Project Requirement: Communicate with maximo through webservices to load
data i.e Post the request xml with data to maximo and get the response from
maximo

Mode of communication: VB.net code to communicate with maximo

Functionality: VB Code should post the maximo supported XML file to the
given maximo Web Services url.

Issue: Below Exception Error is thrown on trying to achieve the above
functionality .Please find below error.

The remote server returned an error: (500) Internal Server Error


Code used to communicate :
VB
Imports System.IO
Imports System.Xml
Imports System.Net

Public Class MainClass

    Shared Sub Main()
        Dim url As String =
"http://122.166.7.149/meaweb/services/PMOASSETINTQRY"

        Dim req As WebRequest = WebRequest.Create(url)
        req.Credentials = CredentialCache.DefaultCredentials


        req.Method = "POST"
        req.ContentType = "text/xml"
        'req.Headers.Add("MI_XMLPROTOCOLREQUEST", "MatrixRouteRequest")
        'req.Headers.Add("MI_XMLPROTOCOLVERSION", "3.2")

        Dim writer As New StreamWriter(req.GetRequestStream())
        Dim reader As New StreamReader("C:\test.xml")

        writer.Write(reader.ReadToEnd())
        Console.WriteLine("Posted to remote server")

        writer.Close()
        reader.Close()

        Dim response As WebResponse = req.GetResponse()
        Dim responseXML As New XmlDocument
        responseXML.Load(response.GetResponseStream())

        Dim twriter As New XmlTextWriter("c:\myresponseVB23.xml",
System.Text.Encoding.UTF8)
        responseXML.WriteTo(twriter)

        twriter.Flush()
        twriter.Close()

        response.GetResponseStream().Close()
        req.GetRequestStream().Close()
    End Sub ' Main

End Class
Posted
Updated 2-Jan-12 7:21am
v2

Try adding a try..catch block around your code and catching a System.Exception type. Using the debugger investigate the exception including all inner exceptions to get the idea what went wrong at server side.
 
Share this answer
 
hi frnd ,

did you host you site on medium trust environmental?

if you use medium trust then please change you trust level,
changes into your web.config related to trust level.

<system.web><trust level="Full" /> ...</system.web>


Hope it will help..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900