WHAT IS SOAP PHP

As application developers, the ability lớn develop software & services for a wide range of platforms is a necessary skill, but not everyone uses the same language or platsize và writing code khổng lồ support them all is not feasible. If only there was a standard that allowed us to write code once và allow others to interact with it from their own software with ease. Well luckily there is… and it’s name is SOAPhường. (SOAP. used to lớn be an acronym which stood for Simple Object Access Protocol, but as of version 1.2 the protocol goes simply by the name SOAPhường.)

SOAP. allows you to lớn build interoperable software & allows others to lớn take advantage of your software over a network. It defines rules for sending and receiving Remote Procedure Calls (RPC) such as the structure of the request & responses. Therefore, SOAPhường is not tied to any specific operating system or programming language. As that matters is someone can formulate and parse a SOAPhường message in their chosen language

In this first of a two part series on website services I’ll talk about the SOAP specification and what is involved in creating SOAP.. messages. I’ll also demonstrate how lớn create a SOAP. VPS & client using the excellent NuSOAP.. library lớn illustrate the flow of SOAPhường. In the second part I’ll talk about the importance of WSDL files, how you can easily generate them with NuSOAPhường as well, and how a client may use a WSDL file khổng lồ better underst& your website service.

Bạn đang xem: What is soap php

The Structure of a SOAP.. Message

SOAP. is based on XML so it is considered human read, but there is a specific schema that must be adhered to lớn. Let’s first break down a SOAPhường message, stripping out all of its data, and just look at the specific elements that make up a SOAPhường message.

... ... ...

This might look like just an ordinary XML file, but what makes it a SOAP message is the root element Envelope with the namespace soap as https://www.w3.org/2001/12/soap-envelope. The soap:encodingStyle attribute determines the data types used in the file, but SOAP. itself does not have sầu a mặc định encoding.

soap:Envelope is mandatory, but the next element, soap:Header, is optional & usually contains information relevant to authentication và session handling. The SOAPhường protocol doesn’t offer any built-in authentication, but allows developers lớn include it in this header tag.

Next there’s the required soap:Body element which contains the actual RPC message, including method names and, in the case of a response, the return values of the method. The soap:Fault element is optional; if present, it holds any error messages or status information for the SOAPhường message and must be a child element of soap:Body.

Now that you underst& the basics of what makes up a SOAP.. message, let’s look at what SOAPhường request và response messages might look lượt thích. Let’s start with a request.

Xem thêm: Apple Revives And Refreshes Game Center In Ios 14 And Macos Big Sur

IBM

Above sầu is an example SOAPhường request message khổng lồ obtain the stock price of a particular company. Inside soap:Body you’ll notice the GetStockPrice element which is specific to lớn the application. It’s not a SOAP element, & it takes its name from the function on the hệ thống that will be called for this request. StockName is also specific lớn the application & is an argument for the function.

The response message is similar lớn the request:

183.08

Inside the soap:Body element there is a GetStockPriceResponse element with a Price child that contains the return data. As you would guess, both GetStockPriceResponse và Price are specific khổng lồ this application.

Now that you’ve seen an example request and response và understvà the structure of a SOAP message, let’s install NuSOAP và build a SOAP client & VPS lớn demonstrate generating such messages.

Building a SOAPhường Server

It couldn’t be easier to get NuSOAP up and running on your server; just visit sourceforge.net/projects/nusoap, download and unzip the package in your website root direoctry, và you’re done. To use the library just include the nusoap.php tệp tin in your code.

For the server, let’s say we’ve been given the task of building a service lớn provide a listing of products given a hàng hóa category. The VPS should read in the category from a request, look up any products that match the category, and return the các mục khổng lồ the user in a CSV format.