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:Envelop e xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/">
<soap:Body>
<IDP_DomainAvai labilityChecker _SingleResponse
xmlns="http://tempuri.org/Safenames_IDP_X ML_API_WebServi ce/Service1">
<IDP_DomainAvai labilityChecker _SingleResult>
<DomainName>str ing</DomainName>
<Success>boolea n</Success>
<CommandName>st ring</CommandName>
<Description>st ring</Description>
</IDP_DomainAvail abilityChecker_ SingleResult>
</IDP_DomainAvail abilityChecker_ 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_X ML_API_WebServi ce/Service1">Paul</DomainName>
<Success xmlns="http://tempuri.org/Safenames_IDP_X ML_API_WebServi ce/Service1">true</Success>
<CommandName xmlns="http://tempuri.org/Safenames_IDP_X ML_API_WebServi ce/Service1">IDP_D omainAvailabili tyChecker(S)</CommandName>
<Description xmlns="http://tempuri.org/Safenames_IDP_X ML_API_WebServi ce/Service1">Avail able</Description>
</IDPResults>
The code im working on...
IDPResults(0) = objAPI.IDP_Doma inAvailabilityC hecker(myLoginK ey,
tbData.Text.ToS tring)
' Try and Serialize class
Dim xmlS1 As New XmlSerializer(G etType(Safename s_WebServices.I DPResults))
Dim swri1 As New System.IO.Strin gWriter
Dim xwri1 As New System.Xml.XmlT extWriter(swri1 )
xwri1.Formattin g = System.Xml.Form atting.None
xmlS1.Serialize (swri1,
objAPI.IDP_Doma inAvailabilityC hecker(myLoginK ey,
tbData.Text.ToS tring))
tbXMLUserReceiv es.Text = swri1.ToString
swri1.Close()
Thanks for your time - No this one is a little long winded.
Paul.