Link to home
Start Free TrialLog in
Avatar of Iain Hodgen
Iain Hodgen

asked on

Convert vb .NET webservice to C~

I have the following function to retrieve an xml string from a web service (which works fine).
Does anyone know how to do the c# equivalent - new to c# and stuck!!

Public Function apwGetCHS() As String
        Dim serviceURL As String = "https://mywebsite.com/provider/proxy/caseExport/"
        Dim paramsSB As New StringBuilder
        Dim ReturnString As String = ""

        'create the parameterised string for the URL
        paramsSB.Append("CHSUserName=myusername")
        paramsSB.Append("&CHSOrganisationID=org")
        paramsSB.Append("&CHSPassword=password")
        paramsSB.Append("&CHSCRN=crn")

        Dim params As String = paramsSB.ToString

        Dim xmldoc As Object
        Dim oxmlHttp As Object

        oxmlHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
        oxmlHttp.Open("POST", serviceURL, False)
        oxmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
        oxmlHttp.send(params)


        'msgbox "ok"
        If oxmlHttp.status = 200 Then

            '     icmd = "alert('" & oxmlHTTP.statusText & "')"
            '     
            xmldoc = CreateObject("Microsoft.XMLDOM")
            xmldoc.loadXML(oxmlHttp.responseText)
            Try
                If FilePath(23) = "" Then
                Else
                    xmldoc.Save("testxml.xml")
                End If
            Catch ex As Exception

            End Try

        Else
            'log the error
        End If

        Return ReturnString
End Function

Open in new window


Cheers,
Iain
SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Iain Hodgen
Iain Hodgen

ASKER

Interaction is not supported in c# apparently
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Author,
Is this done :) ?

Regards,
Pawan
Hi Iain;

Still waiting a response from my last post. Did that resolve the issue?