1. Este site usa cookies. Ao continuar a usar este site está a concordar com o nosso uso de cookies. Saber Mais.

Server did not recognize the value of HTTP Header SOAPAction

Discussão em 'Web Development' iniciada por BrunoGomes_PT, 6 de Junho de 2018. (Respostas: 0; Visualizações: 151)

  1. BrunoGomes_PT

    BrunoGomes_PT Power Member

    Boas, estou a tentar implementar um webservice de um software chamado SmarterTrack só que não estou a conseguir... dá-me o seguinte erro:
    Server did not recognize the value of HTTP Header SOAPAction: http://localhost:9996/Services2/svcTickets.asmx?op=CreateTicket.
    Já testei diretamente no browser e funciona extremamente bem.
    Alguém me pode ajudar? Agradecia imenso.

    Código:
     Sub Execute()
            Dim request As HttpWebRequest = CType(WebRequest.Create("http://localhost:9996/Services2/svcTickets.asmx"), HttpWebRequest)
            request.Method = "POST"
            request.Host = "localhost:9996"
            request.ContentType = "text/xml; charset=utf-8"
            request.Headers.Add("SOAPAction", "http://localhost:9996/Services2/svcTickets.asmx?op=CreateTicket")
            request.Method = "POST"
            Dim soapEnvelopeXml As New XmlDocument()
            soapEnvelopeXml.LoadXml("<?xml version=""1.0"" encoding=""utf-8""?>" & ControlChars.CrLf &
            "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & ControlChars.CrLf &
            "<soap:Body>" & ControlChars.CrLf &
            "<CreateTicket xmlns=""http://localhost:9996/Services2/svcTickets.asmx"">" & ControlChars.CrLf &
            "<authUserName>admin</authUserName>" & ControlChars.CrLf &
            "<authPassword>teste123</authPassword>" & ControlChars.CrLf &
            "<departmentID>3</departmentID>" & ControlChars.CrLf &
            "<groupId>3</groupId>" & ControlChars.CrLf &
            "<userIdOfAgent>2</userIdOfAgent>" & ControlChars.CrLf &
            "<toAddress>[email protected]</toAddress>" & ControlChars.CrLf &
            "<subject>test</subject>" & ControlChars.CrLf &
            "<body>teste</body>" & ControlChars.CrLf &
            "<isHtml>True</isHtml>" & ControlChars.CrLf &
            "<setWaiting>True</setWaiting>" & ControlChars.CrLf &
            "<sendEmail>True</sendEmail>" & ControlChars.CrLf &
            "</CreateTicket>" & ControlChars.CrLf &
            "</soap:Body>" & ControlChars.CrLf &
            "</soap:Envelope>")
            Using stream As Stream = request.GetRequestStream()
                soapEnvelopeXml.Save(stream)
            End Using
            Using response As WebResponse = request.GetResponse()
                Using rd As New StreamReader(response.GetResponseStream())
                    Dim soapResult As String = rd.ReadToEnd()
                    Console.WriteLine(soapResult)
                End Using
            End Using
        End Sub
     

Partilhar esta Página