Use of WSMessage in PHP Web Services

Thursday, January 3, 2008

In a Web services invocation, there are two messages involved, for two way operations. One is the request message and the other is the response message. WSMessage class in the Web services framework for PHP is used to represent these messages.

The str member variable of the WSMessage class can hold the the message content, termed as payload, as an XML string.

If you are sending a request, form a client, you can fill in the request WSMessage instance with the XML payload and send it. The received response payload will be stored in a WSMessage instance as an XML string and returned to client.

If you are receiving a request, form a service, the received request payload will be contained in a WSMessage instance. You can process the request, prepare the response, store it in a WSMessage instance and return that instance.

WSMessage is more useful when sending and receiving attachments than when dealing with simple messages. We will look how to leverage WSMessage in case of attachments in the future.

No comments: