Web Services de Notificação

Introduction

Information about the Web Services that the provider can implement to receive notifications from the MPS Portal.

Web Services

Web service

Description

MPSEventsNotification

Web service implemented on the client side to receive notifications from the MPS Portal regarding system events or printer events

MPSOrdersNotification

Web service implemented on the client side to receive notifications from the MPS Portal regarding changes to orders and deliveries assigned to Distribution Centers and Suppliers

Security

To ensure that data is transmitted securely, it is important that these Web Services be published in a way that allows them to be accessed via a secure protocol (HTTPS).

Sending a Response to the MPS Portal

All methods you want to implement must return an string in XML format containing the result of the call. Below are two examples of responses: one for a successful XML response and another for a failure:

<?xml version="1.0" encoding="utf-8" ?>
<ResultData>
   <ResultValue>true</ResultValue>
   <ResultError />
</ResultData> 

<?xml version="1.0" encoding="utf-8" ?>
<ResultData>
   <ResultValue>false</ResultValue>
   <ResultError>Server Application Unavailable</ResultError>
</ResultData>
  • ResultValue: the result of the web service call. Whether it was successful or there was a failure;

  • ResultError: a description of the type of error that occurred when there was a failure in the operation.


View a simple example of how to set up the callback for MPS in C#:

C#
using System.Xml; 

public class ResponseBuilder
{
    private string FormatResultData(bool resultValue, string resultError)
    {
        XmlDocument xmlDoc = new XmlDocument();
        XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
        XmlElement rootNode = xmlDoc.CreateElement("ResultData"); 

        xmlDoc.InsertBefore(xmlDeclaration, xmlDoc.DocumentElement);
        xmlDoc.AppendChild(rootNode); 

        XmlElement valueNode = xmlDoc.CreateElement("ResultValue");
        XmlElement errorNode = xmlDoc.CreateElement("ResultError"); 

        XmlText valueText = xmlDoc.CreateTextNode(resultValue.ToString());
        XmlText errorText = xmlDoc.CreateTextNode(resultError); 

        rootNode.AppendChild(valueNode);
        rootNode.AppendChild(errorNode); 

        valueNode.AppendChild(valueText);
        errorNode.AppendChild(errorText); 

        return xmlDoc.InnerXml;
    }
}