Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning XML response before method
Message
De
12/12/2016 09:36:19
 
Information générale
Forum:
ASP.NET
Catégorie:
Web Services
Versions des environnements
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows Server 2012
Database:
Visual FoxPro
Application:
Web
Divers
Thread ID:
01644778
Message ID:
01644909
Vues:
35
>You can also use SOAP headers for this. But again - quite awkward to implement.

I had it ok. I just needed to encode the XML that I am returning as a parameter.

So, basically, a normal process will, eventually, get into the WebService method to return the response. However, in the entry code, one which is executed before each WebService method, if I need to intercept the call, I just switch it off to System.Web.HttpResponse:
' Intercept the execution
Public Function InterceptExecution() As Boolean
   Dim loHttpResponse As System.Web.HttpResponse = Nothing

   loHttpResponse = System.Web.HttpContext.Current.Response
   loHttpResponse.Clear()
   loHttpResponse.ClearContent()
   loHttpResponse.ClearHeaders()
   loHttpResponse.ContentType = "text/xml"
   loHttpResponse.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8")
   loHttpResponse.Write(cXml)
   loHttpResponse.End()

   Return True
End Function
The cXml property is constructed from a SOAP envelope:
' Return a XML response with a full SOAP envelope
Public Function GetXmlSOAPEnvelope() As String
   Dim lcSOAP As String = ""
   Dim lcXml As String = ""

   ' Get the Xml
   oWebServiceClient.lSuccess = lSuccess
   oWebServiceClient.lEncode = True
   If oWebServiceClient.GetXml() Then
   End If

   ' Initialization
   lcXml = oWebServiceClient.cXML

   lcSOAP = lcSOAP + "<?xml version=""1.0"" encoding=""utf-8""?>"
   lcSOAP = lcSOAP + "<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" " +
    "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" " +
    "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">"
   lcSOAP = lcSOAP + "<soap:Body>"
   lcSOAP = lcSOAP + "<" + cMethod + "Response xmlns=""http://tempuri.org/WebService/Service1"">"
   lcSOAP = lcSOAP + "<" + cMethod + "Result>"
   lcSOAP = lcSOAP + lcXml
   lcSOAP = lcSOAP + "</" + cMethod + "Result>"
   lcSOAP = lcSOAP + "</" + cMethod + "Response>"
   lcSOAP = lcSOAP + "</soap:Body>"
   lcSOAP = lcSOAP + "</soap:Envelope>"

   Return lcSOAP
End Function
The oWebServiceClient is simply a class which define a proper protocol for returning the Xml based on our standards.

Thanks for the response
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform