ASP.NET
Change web service content-type on response
Gravatar is a globally recognized avatar based on your email address. Change web service content-type on response
  stevieg
  All
  Aug 11, 2021 @ 07:58am

I have a webservice I created in VS 2019. The only thing it does is listens for messages from a vendor of ours. The message is a simple soap message with some xml in a <![CDATA[] section. If I use SOAPUI to test my service using sample data they sent me, it works fine. However, when I put it on the server I always get error 500 from IIS. According to their technical person, they can only respond to a response of "OK" (200) and the content-type must be : application/x-www-form-urlencoded

How can I get my web service to respond in that manner?

Any help would be greatly appreciated, Thanks.

The code is below:

<System.Web.Services.WebService(Namespace:="--------------------------------------")>
<SoapDocumentService(ParameterStyle:=SoapParameterStyle.Default)>
<ToolboxItem(False)>
Public Class ISOClaimSearch
    Inherits System.Web.Services.WebService
    <WebMethod()>
    Public Function ClaimInvestigationRiskUpdate(ClaimInvestigationRiskUpdateRs As ClaimInvestigationRiskUpdateRs) As HttpStatusCode

        'ISOClaimSearchWebService.My.Response.ContentType = "application/x-www-form-urlencoded"

        'Dim myHttpWebRequest As WebRequest
        'myHttpWebRequest.Method = "POST"
        'myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"

        Dim file As System.IO.StreamWriter
        Dim Logdata As String = ""

        Try
            file = My.Computer.FileSystem.OpenTextFileWriter("c:\temp\ISOClaimSearchGotSomething.txt", True) 'False to overwrite, True to append
            file.WriteLine(Logdata & vbCrLf & "Got Something..." & vbCrLf & vbCrLf & DateTime.Now & vbCrLf & vbCrLf)
            file.Close()

        Catch ex As Exception
            file = My.Computer.FileSystem.OpenTextFileWriter("c:\temp\ISOClaimSearchGotSomething.txt", True) 'False to overwrite, True to append
            file.WriteLine(Logdata & vbCrLf & "Some kind of failure..." & vbCrLf & vbCrLf)
            file.Close()
            Return HttpStatusCode.NotAcceptable 'send 406
            Exit Function
        End Try


        Try

            file = My.Computer.FileSystem.OpenTextFileWriter("c:\temp\ISOClaimSearchLog.txt", True) 'False to overwrite, True to append
            file.WriteLine(Logdata & vbCrLf & "Database Connection Opening..." & vbCrLf & vbCrLf & DateTime.Now & vbCrLf & vbCrLf & ClaimInvestigationRiskUpdateRs.xml.Value)
            file.WriteLine(Logdata & vbCrLf & "Database Connection Closing..." & vbCrLf)
            file.Close()

            Return HttpStatusCode.OK 'send 200

        Catch ex As Exception
            Return HttpStatusCode.ExpectationFailed
            file = My.Computer.FileSystem.OpenTextFileWriter("c:\temp\ISOClaimSearchLog.txt", True) 'False to overwrite, True to append
            file.WriteLine(Logdata & vbCrLf & "Connection or data resolution failed..." & vbCrLf & vbCrLf)
            file.Close()
            Return HttpStatusCode.NotAcceptable 'send 406
            Exit Function
        End Try

    End Function

End Class


Gravatar is a globally recognized avatar based on your email address. re: Change web service content-type on response
  KevinH
  stevieg
  Aug 6, 2024 @ 07:32am

Stevieg,

I am having a similar issue with a webservice I created in VS2022 that is to receive a post back from isoclaimsearch (verisk).

Just curious, did you find a solution?

© 1996-2025