Im currently developing an API using a vb.net web service. Im very
nearly there as regard to functionality but would like to add a
feature so that users can see exactly what xml is being generated
(sent and received) for each API command.
Picture the scenario. I have a UI which contains the following...
Multiline text box: Friendly response from API (Displays results)
Multiline text box: XML Sent (would like to display xml sent)
Multiline text box: XML Received (would like to display xml received)
The API commands work fine and display the correct results in the
"Friendly response from API" box. Also, if I browse directly to the
Web Service I get a convinient screen showing all exposed commands
(web methods) as hyperlinks that the Web Service contains. If I click
on one of these hyperlinks I get another convinient screen showing
what the method expects to see from a posted SOAP message and a posted
HTTP POST and the responses the method will throw back.
What I would like to do is somehow serialse my API commands so that
when a user clicks an API command button the "XML Sent" and "XML
Received" boxes are automatically populated with what is sent \
recieved behind the scenes.
I think im close (but no cigar) at the moment. Im using the following
code to try and serialse the command \ data type but the response
being displayed in my "XML Received" text box does not match the auto
generated SOAP response which I discussed earlier. Think it may have
something to do with either name spaces or the way SOAP works? Any
ideas or pointers would be very much appriciated.
What my xml should look like...
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<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/">
<soap:Body>
<IDP_DomainAvailabilityChecker_SingleResponse
xmlns="http://tempuri.org/Safenames_IDP_XML_API_WebService/Service1">
<IDP_DomainAvailabilityChecker_SingleResult>
<DomainName>string</DomainName>
<Success>boolean</Success>
<CommandName>string</CommandName>
<Description>string</Description>
</IDP_DomainAvailabilityChecker_SingleResult>
</IDP_DomainAvailabilityChecker_SingleResponse>
</soap:Body>
</soap:Envelope>
And what is displayed in my "XML Recived" text box...
<?xml version="1.0" encoding="utf-16"?>
<IDPResults xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DomainName xmlns="http://tempuri.org/Safenames_IDP_XML_API_WebService/Service1">Paul</DomainName>
<Success xmlns="http://tempuri.org/Safenames_IDP_XML_API_WebService/Service1">true</Success>
<CommandName xmlns="http://tempuri.org/Safenames_IDP_XML_API_WebService/Service1">IDP_DomainAvailabilityChecker(S)</CommandName>
<Description xmlns="http://tempuri.org/Safenames_IDP_XML_API_WebService/Service1">Available</Description>
</IDPResults>
The code im working on...
IDPResults(0) = objAPI.IDP_DomainAvailabilityChecker(myLoginKey,
tbData.Text.ToString)
' Try and Serialize class
Dim xmlS1 As New XmlSerializer(GetType(Safenames_WebServices.IDPRes ults))
Dim swri1 As New System.IO.StringWriter
Dim xwri1 As New System.Xml.XmlTextWriter(swri1)
xwri1.Formatting = System.Xml.Formatting.None
xmlS1.Serialize(swri1,
objAPI.IDP_DomainAvailabilityChecker(myLoginKey,
tbData.Text.ToString))
tbXMLUserReceives.Text = swri1.ToString
swri1.Close()
Thanks for your time - No this one is a little long winded.
Paul.