Dear Friends..
I do the post soap api in the powerbuilder..its works good..but iam unable to do the GetAll and Get by id soap api in powerbuilder..because of i dont get any resources....i will share my working for how to do the soap Getall and Getby..
https://localhost:44339/McDonaldsSoapService.asmx?op=GetAllMcDonalds
SOAP 1.1
The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.
POST /McDonaldsSoapService.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetAllMcDonalds"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetAllMcDonalds xmlns="http://tempuri.org/">
<requestDTO />
</GetAllMcDonalds>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetAllMcDonaldsResponse xmlns="http://tempuri.org/"> <GetAllMcDonaldsResult> <GetAllMcDonaldsResponseDTO> <ID>string</ID> <MENU>string</MENU> <PRICE>string</PRICE> <DESCRIPTION>string</DESCRIPTION> </GetAllMcDonaldsResponseDTO> <GetAllMcDonaldsResponseDTO> <ID>string</ID> <MENU>string</MENU> <PRICE>string</PRICE> <DESCRIPTION>string</DESCRIPTION> </GetAllMcDonaldsResponseDTO> </GetAllMcDonaldsResult> </GetAllMcDonaldsResponse> </soap:Body> </soap:Envelope>
This is the code for Csharp.
[WebMethod]
public List<GetAllMcDonaldsResponseDTO> GetAllMcDonalds(GetAllMcDonaldsRequestDTO requestDTO)
{
List<GetAllMcDonaldsResponseDTO> response = new List<GetAllMcDonaldsResponseDTO>();
// Query the data from your data source (MCDONALDS table)
var data = _service.MCDONALDS.ToList();
// Map the data to your response DTO
foreach (var item in data)
{
response.Add(new GetAllMcDonaldsResponseDTO
{
ID = item.ID,
MENU = item.MENU,
PRICE = item.PRICE,
DESCRIPTION = item.DESCRIPTION
});
}
return response;
}
Post code is works Good.....i will share that code also..httpClient lo_client
integer li_ret // 1
integer li_StatusCode // 200
string ls_url // endpoint
string ls_data // response
string ls_body // xml to send
string ls_ret // OK
ls_url ="https://localhost:44339/McDonaldsSoapService.asmx?op=InsertMcdonalds"
ls_body += '<?xml version="1.0" encoding="utf-8"?>'
ls_body += '<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">'
ls_body += ' <soap12:Body>'
ls_body += ' <InsertMcdonalds xmlns="http://tempuri.org/">'
ls_body += ' <request>'
ls_body += ' <MENU>FISHPOLLO</MENU>'
ls_body += '<PRICE>21</PRICE>'
ls_body += '<DESCRIPTION>string</DESCRIPTION>'
ls_body += ' </request>'
ls_body += '</InsertMcdonalds>'
ls_body += '</soap12:Body>'
ls_body += '</soap12:Envelope>'
lo_client = Create httpClient
lo_client.SetRequestHeader("Content-Type","application/soap+xml; charset=utf-8") // "text/xml")
lo_Client.SetRequestHeader("Content-Length", string(len(ls_body)))
lo_client.sendrequest('POST', ls_url, ls_body)
li_StatusCode = lo_client.GetResponseStatusCode()
ls_ret = lo_client.GetResponseStatusText( )
li_ret = lo_client.getresponsebody( ls_data)
destroy lo_client
messagebox("Service response", ls_data)...
I need Get by Id and GEt all for soap api in power builder .can any one help me..?