1. Pbuser12 Ateikon
  2. PowerBuilder
  3. Tuesday, 17 October 2023 09:51 AM UTC

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..?





Pbuser12 Ateikon Accepted Answer Pending Moderation
  1. Wednesday, 18 October 2023 10:26 AM UTC
  2. PowerBuilder
  3. # 1

Dear Andreads,

 

Its Working ..Now If i tried this 

lo_client.SetRequestHeader("Content-Type","text/xml; charset=utf-8")

 

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 18 October 2023 07:27 AM UTC
  2. PowerBuilder
  3. # 2

In your code you have the following command:

lo_client.SetRequestHeader("Content-Type","application/soap+xml; charset=utf-8") // "text/xml")

Have you tried:

lo_client.SetRequestHeader("Content-Type","text/xml; charset=utf-8")

// or 
//lo_client.SetRequestHeader("Content-Type","text/xml;")

and it didn't worked?

In the sample you provided the content-type used is as follows:

Andreas.

Comment
There are no comments made yet.
Pbuser12 Ateikon Accepted Answer Pending Moderation
  1. Wednesday, 18 October 2023 06:48 AM UTC
  2. PowerBuilder
  3. # 3

Dear Andrea,

 

 Thank you for your reply..I cant understand ..what you said to me.could you please explain me clearly..

 

 

Now I have to do the Soap Get response in power builder...

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Tuesday, 17 October 2023 10:09 AM UTC
  2. PowerBuilder
  3. # 4

Hi.

Your sample soap 1.1 have content type text/xml...

Andreas.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.