Iam doing a getAll soap api in power builder. I got status is 200 and ok..but i didnot get the response .can any one help me ..
Code sytax:
integer li_ret
integer li_StatusCode
string ls_url,ls_soap_action
string ls_data
string ls_body
string ls_ret
// Create an HTTP client object
httpClient lo_client
lo_client = Create httpClient
// Set the URL for the SOAP GET request
ls_url = "https://localhost:44339/McDonaldsSoapService.asmx"
ls_body ='<?xml version="1.0" encoding="utf-8"?>'
ls_body +='<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/">'
ls_body +='<soap:Body>'
ls_body +='GetAllMcDonalds xmlns="http://tempuri.org/">'
ls_body += '<requestDTO />'
ls_body +='</GetAllMcDonalds>'
ls_body +='</soap:Body>'
ls_body +='</soap:Envelope>'
// Set the request headers for a SOAP GET request
lo_client.SetRequestHeader("Content-Type", "text/xml; charset=utf-8")
lo_client.SetRequestHeader("Content-Length", String(Len(ls_body)))
//// Send the SOAP GET request
lo_client.sendrequest('GET', 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 will provide soap wsdl file:
GetAllMcDonalds
Test
The test form is only available for methods with primitive types as parameters.
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>
Error message:
li_ret = lo_client.getresponsebody(ls_data) :in this line i got error..
<html>
<head><link rel="alternate" type="text/xml" href="/McDonaldsSoapService.asmx?disco" />
<style type="text/css">
BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; }
#content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; }
A:link { color: #336699; font-weight: bold; text-decoration: underline; }
A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; }
A:active { color: #336699; font-weight: bold; text-decoration: underline; }
A:hover { color: cc3300; font-weight: bold; text-decoration: underline; }
P { color: #000000; margin-top: 0px; margin-bottom: 12px; font-family: Verdana; }
pre { background-color: #e5e5cc; padding: 5px; font-family: Courier New; font-size: x-small; margin-top: -5px; border: 1px #f0f0e0 solid; }
td { color: #000000; font-family: Verdana; font-size: .7em; }
h2 { font-size: 1.5em; font-weight: bold; margin-top: 25px; margin-bottom: 10px; border-top: 1px solid #003366; margin-left: -15px; color: #003366; }
h3 { font-size: 1.1em; color: #000000; margin-left: -15px; margin-top: 10px; margin-bottom: 10px; }
ul { margin-top: 10px; margin-left: 20px; }
ol { margin-top: 10px; margin-left: 20px; }
li { margin-top: 10px; color: #000000; }
font.value { color: darkblue; font: bold; }
font.key { color: darkgreen; font: bold; }
font.error { color: darkred; font: bold; }
.heading1 { color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal; background-color: #003366; margin-top: 0px; margin-bottom: 0px; margin-left: -30px; padding-top: 10px; padding-bottom: 3px; padding-left: 15px; width: 105%; }
.button { background-color: #dcdcdc; font-family: Verdana; font-size: 1em; border-top: #cccccc 1px solid; border-bottom: #666666 1px solid; border-left: #cccccc 1px solid; border-right: #666666 1px solid; }
.frmheader { color: #000000; background: #dcdcdc; font-family: Verdana; font-size: .7em; font-weight: normal; border-bottom: 1px solid #dcdcdc; padding-top: 2px; padding-bottom: 2px; }
.frmtext { font-family: Verdana; font-size: .7em; margin-top: 8px; margin-bottom: 0px; margin-left: 32px; }
.frmInput { font-family: Verdana; font-size: 1em; }
.intro { margin-left: -15px; }
</style>
<title>
McDonaldsSoapService Web Service
</title></head>
<body>
<div id="content">
<p class="heading1">McDonaldsSoapService</p><br>
<span>
<p class="intro">The following operations are supported. For a formal definition, please review the <a href="/McDonaldsSoapService.asmx?WSDL">Service Description</a>. </p>
<ul>
<li>
<a href="/McDonaldsSoapService.asmx?op=GetAllMcDonalds">GetAllMcDonalds</a>
</li>
<p>
<li>
<a href="/McDonaldsSoapService.asmx?op=InsertMcdonalds">InsertMcdonalds</a>
</li>
<p>
</ul>
</span>
<span>
</span>
<span>
<hr>
<h3>This web service is using http://tempuri.org/ as its default namespace.</h3>
<h3>Recommendation: Change the default namespace before the XML Web service is made public.</h3>
<p class="intro">Each XML Web service needs a unique namespace in order for client applications to distinguish it from other services on the Web. http://tempuri.org/ is available for XML Web services that are under development, but published XML Web services should use a more permanent namespace.</p>
<p class="intro">Your XML Web service should be identified by a namespace that you control. For example, you can use your company's Internet domain name as part of the namespace. Although many XML Web service namespaces look like URLs, they need not point to actual resources on the Web. (XML Web service namespaces are URIs.)</p>
<p class="intro">For XML Web services creating using ASP.NET, the default namespace can be changed using the WebService attribute's Namespace property. The WebService attribute is an attribute applied to the class that contains the XML Web service methods. Below is a code example that sets the namespace to "http://microsoft.com/webservices/":</p>
<p class="intro">C#</p>
<pre>[WebService(Namespace="http://microsoft.com/webservices/")]
public class MyWebService {
// implementation
}</pre>
<p class="intro">Visual Basic</p>
<pre><WebService(Namespace:="http://microsoft.com/webservices/")> Public Class MyWebService
' implementation
End Class</pre>
<p class="intro">C++</p>
<pre>[WebService(Namespace="http://microsoft.com/webservices/")]
public ref class MyWebService {
// implementation
};</pre>
<p class="intro">For more details on XML namespaces, see the W3C recommendation on <a href="http://www.w3.org/TR/REC-xml-names/">Namespaces in XML</A>.</p>
<p class="intro">For more details on WSDL, see the <a href="http://www.w3.org/TR/wsdl">WSDL Specification</a>.</p>
<p class="intro">For more details on URIs, see <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>.</p>
</span>
<!-- Visual Studio Browser Link -->
<script type="text/javascript" src="https://localhost:44399/600af583361b4e6b80adad702446c17c/browserLink" async="async" id="__browserLink_initializationData" data-requestId="6f848c93883c426bac074f34f0f6c658" data-appName="Unknown"></script>
<!-- End Browser Link -->
</body>
</html>