I have made application for SAP on iPad in xcode framework. Using web view method I am able to open my application webpages in iPad. html5 pages are store on my pc.
My question is how to consume SAP SOAP web-service through html5 webpages. What steps should I make first? I have access of SAP ES workplace. I dont have any idea about this as this is my first project. Can some one provide me the proper Video tutorial or specific links to read.
Most of link are for REST ful web services. Thanks in Advance.
And my web service url is
"http://erp.esworkplace.sap.com/sap/bc/srt/wsdl/bndg_DF5300E043F279F18F0400145E5ADE89/wsdl11/allinone/ws_policy/document?sap-client=800" which opens in wsdl format.
And "MaterialBasicDataByIDQueryResponse_In" this is my function name
I highly recommend REST! It's a lot more light weight
I user jQuery in this example
In your html page
<script id="soap-template" type="application/soap-template"> <?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><ns0:getSOAP xmlns:ns0="http://localhost:8080/soap"> <search>${id}</search></ns0:getSOAP ></soap:Body></soap:Envelope></script>
JS:
var soapBody = $("#soap-template").html().replace(
new RegExp( "\\$\\{[^}]+\\}", "i" ),
search
);
soapBody = $.trim( soapBody );
$.ajax({
type: "post",
url: "http://localhost:8080/soap",
contentType: "text/xml",
data: soapBody,
dataType: "xml",
processData: false,
beforeSend: function( xhr ){
// Pass the target URL onto the proxy.
xhr.setRequestHeader(
"SOAPTarget",
"http://localhost:8080/soap"
);
// Pass the action onto the proxy.
xhr.setRequestHeader(
"SOAPAction",
"http://localhost:8080/soap/getSOAP"
);
},
success: function( response ){
// Get a jQuery-ized version of the response.
var xml = $( response );
//handle your result
},
error: function(){
alert("error");
console.log( "ERROR", arguments );
}
});
Related
I'm making an AJAX POST request from ember-cli to django rest framework in order to enable user to download excel/xls file. However, I'm stuck into formating problem, the file pops up but the content of the xls is not in correct format.
Here's the code I use in the controller:
Ember.$.ajax({
type: "POST",
url: "http://api.dev.maspa.biz/api/v1/panel/catalog/export",
data: 'ids=' + ids,
success: function(data) {
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:application/vnd.ms-excel' + encodeURI(data);
hiddenElement.target = '_blank';
hiddenElement.download = 'export.xls';
hiddenElement.click();
},
})
Looking for your helpful reply.
Thanks
Have you thought about using an ember addon to handle this export for you? It could be more reliable than coding it yourself.
Check out this add-on - https://github.com/roofstock/ember-cli-data-export.
I am trying to call ASP.net 1.1 service in asp.net using Jquery, can't figure put what I am doing wrong here, Pleaseeeee help
Javascript Method
function YesCheckChanged(vSRID) {
var para = {
SRID: vSRID
};
jQuery.ajax({
type: "POST",
url: serviceUrl + "/YesRdoClicked",
dataType: "xml",
data: para,
contentType: "application/xml; charset=utf-8",
success: function(data, status) {
alert(data);
edata = $(data).find("string").text();
alert(edata);
},
error: function(e, status) {
alert(status);
}
});
}
Error
System.InvalidOperationException: Request format is invalid:
application/xml; charset=utf-8.
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
Service method Code
[WebMethod(true)]
public string YesRdoClicked(int SRID)
{
clsEntity obj = new clsEntity();
obj.New_DeleteTempEntity(SRID);
return "yes";
}
http://www.codeproject.com/Articles/1231/ASP-NET-Web-Service
I finally resorted to native Activex calls as no other way seem to work for me. Personally I wanted to avoid using it. But It works well.
A word of caution here, activeX are not very well supported in browsers other than IE so you need to either have IE Only application or convince the client to upgrade to higher version of asp.net.
Hi I am trying to call a WCF web service(.svc)
$.ajax({
url: 'http://www.somedoamin.com/Services/service.svc',
dataType: "text/xml",
contentType:'text/xml; charset=utf-8',
beforeSend: function(xhr){
// Pass the soap action onto the proxy.
xhr.setRequestHeader(
"SOAPAction","http://www.anotherdomain.com/Services/Login"
);
},
data:soapMessage,
type: 'POST',
success: function(res) {
var myXML = res.responseText;
console.log('Response ',myXML);
},
error:function(jqXHR, textStatus, errorThrown,exception) {
console.log('An error occured ');
}
});
I am getting error callback. "An error occured"
So, Should i need to add some parameters to WCF Service ?
Refer this existing How Do I call A WCF Web Service from jQuery?
This is the solution they given
http://www.west-wind.com/weblog/posts/2008/Apr/21/jQuery-AJAX-calls-to-a-WCF-REST-Service
Hi i created a plugin portlet. In the JSP i am accessing all countries list by using JSON API. It is working fine for Logged in users. But for the Guest users i am unable to access the web service. I am working on Liferay 6.0.6. The following is my code.
Liferay.Service.Portal.Country.getCountries(
{},
function(result) {
for(var count=0;count< result.length;count++){
alert(result[count].name);
var option = document.createElement("option");
}
}
);
Assuming that you are using Liferay 6.1, you can achieve it by adding a property to portal-ext.properties file
json.service.public.methods=getCountries
If you need to check the whole flow checkout
JSONServiceAction
I think you need to pass the serviceContext with permissions to the Service.
Can you try by setting the communityPermissions and guestPermissions as VIEW ?
Liferay.Service.Portal.Country.getCountries(
{
serviceContext: jQuery.toJSON(
{
communityPermissions: communityPermission,
guestPermissions: guestPermission,
scopeGroupId: themeDisplay.getScopeGroupId()
}
)
},
function(result) {
for(var count=0;count< result.length;count++){
alert(result[count].name);
var option = document.createElement("option");
}
}
);
I found a work around for the above problem. I am unable to access JSON API because Liferay is using A.io.request for AJAX Calls which is available for Logged in Users only. So I have prepared the following code.
jQuery.ajax({
type: "POST",
url: '<%=themeDisplay.getURLPortal() %>'+'/tunnel-web/json?serviceClassName=com.liferay.portal.service.CountryServiceUtil&serviceMethodName=getCountries',
dataType: 'json',
success: function(countriesList) {
alert(countriesList);
alert(countriesList[0].countryId);
}
}
});
I am calling the following jQuery code on page load to test the concept of calling an external web service from the client. The data object in the success callback is always empty. What am I doing wrong?
$.ajax({
url: "http://www.google.com/search",
type: 'GET',
data: { q: "green tea" },
success: function(data) { alert("Data Loaded: " + data) },
dataType: "text/html"
});
It's the same-origin policy you're hitting here, it's specifically in place to prevent cross-domain calls for security reasons. The expected behavior is for the response to be empty here.
You either need to fetch the data via JSONP or get the data via your own domain, your server proxying the request.
It's worth noting Google has a full JavaScript API for searching that you may want to check out for doing this.
browser dont allow you to make cross domain request(a security feature). there is a hack for that with a limitation that you can get only json as response.
----the trick (hack)----
using jquery(or javascript)you create a new script tag and with src="url_of_third_party?", when that request is made you get json from cross site.
jQuery('body').append('<script src="cross_site_url" type="text/javascript"></script>');
or simply you can do this
$.ajax({
url: "http://www.google.com/search",
type: 'GET',
data: { q: "green tea" },
success: function(data) { alert("Data Loaded: " + data) },
dataType: "jsonp",
});
note: dataType=jsonp