Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
langxml
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <PwsAuthenticateResponse xmlns="http://projectorpsa.com/PwsProjectorServices/">
         <PwsAuthenticateResult xmlns:a="http://projectorpsa.com/DataContracts/Responses/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <Messages xmlns="http://projectorpsa.com/CommonServices/" xmlns:b="http://projectorpsa.com/DataContracts/Shared/Common/"/>
            <ResponseId xmlns="http://projectorpsa.com/CommonServices/">12345</ResponseId>
            <Status xmlns="http://projectorpsa.com/CommonServices/">Ok</Status>
            <a:RedirectUrl i:nil="true"/>
            <a:SessionTicket>AVLdSsy+jR9ugkxLQ6hRnw==</a:SessionTicket>
         </PwsAuthenticateResult>
      </PwsAuthenticateResponse>
   </s:Body>
</s:Envelope>



Outputting XML in C#

When debugging, it's often useful to view the raw request/response XML. You can use the following code example to make your request/response XML accessible and output it to a log file or console.

Code Block
languagec#
using System.IO;


       //pass in a Projector request or response object and it will be converted to XML and written to the console window
        private void DumpXML(object requestOrResponseObject) {

            if (debug) { 
                var serxml = new System.Xml.Serialization.XmlSerializer(requestOrResponseObject.GetType());
                var ms = new MemoryStream();
                serxml.Serialize(ms, requestOrResponseObject);
                string xml = Encoding.UTF8.GetString(ms.ToArray());
                Console.WriteLine(xml);
                Console.WriteLine("");
            }
        }
  
      //example calls for a request and a response
      private int GetActiveClientCount(PwsProjectorServicesClient psc, string sessionticket, string query, bool inactiveFlag) {

            var gclRq = new PwsGetClientListRq()
            {
                SessionTicket = sessionticket,
                QueryString = query,
                IncludeInactiveFlag = inactiveFlag
            };

            PwsGetClientListRs gclRs = psc.PwsGetClientList(gclRq);

            DumpXML(gclRq);
            DumpXML(gclRs);

            return gclRs.Clients.Length;
        }