I'm new in sencha touch and I want consuming a SOAP WS like this.
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<register_user soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<a xsi:type="xsd:string">?</a>
<b xsi:type="xsd:string">?</b>
<c xsi:type="xsd:string">?</c>
<d xsi:type="xsd:string">?</d>
</register_user>
</soapenv:Body>
</soapenv:Envelope>
This aplication will be a hybrid aplication in android,
Help! please.
You could populate your stores in the application by doing something like this:
var store = Ext.create('Ext.data.Store', {
autoLoad: true,
model: 'MyModel',
proxy: {
type: 'ajax',
url: 'myURL',
reader: {
type: 'xml',
root: 'data'
},
writer: {
type: 'json'
}
},
listeners: {
//[...]
}
});
Please see Ext.data.Store for more information. You can also see Ext.data.RestProxy for CRUD actions.
Hope it helps!
Related
I am attempting to connect to a SOAP web service that implements its WS security by means of a SOAP header element using the Loopback SOAP connector.
Unfortunately, documentation regarding how to configure the soap header option of the connector is sparse.
It would be greatly appreciated if you could assist by indicating how the soap header should be constructed in order for the web service to authenticate successfully.
var loopback = require('loopback');
var path = require('path');
var app = module.exports = loopback();
app.set('restApiRoot', '/api');
var myHeader = {
Security:
{
UsernameToken:{
Username: "Staging Integration Store 3",
Password: "WSAUFbw6"
}
}
};
var ds = loopback.createDataSource('soap',
{
connector: require('../index'),
/* security: {
scheme: 'wsse',
created: null,
username: "Staging Integration Store 3",
password: "WSAUFbw6",
passwordType: 'PasswordText'
}, */
soapHeaders: [{
element: myHeader, // The XML element in JSON object format
prefix: 'wsse', // The XML namespace prefix for the header
namespace: 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' // The XML namespace URI for the header
}],
remotingEnabled: true,
// wsdl: 'https://staging.payu.co.za/service/PayUAPI?wsdl' // The url to WSDL
wsdl: path.join(__dirname, './PayUAPI.wsdl')
});
// Unfortunately, the methods from the connector are mixed in asynchronously
// This is a hack to wait for the methods to be injected
ds.once('connected', function () {
// Create the model
// var WeatherService = ds.createModel('WeatherService', {});
var RedirectPaymentService = ds.createModel('RedirectPaymentService', {});
// Refine the methods
RedirectPaymentService.payments = function (api,safekey,transactiontype,additionalInfo,customer,basket,cb) {
RedirectPaymentService.setTransaction({Api: api,Safekey: safekey,TransactionType: transactiontype,AdditionalInformation: additionalInfo,Customer: customer,Basket: basket}, function (err, response) {
console.log('SetTransaction: %j', response);
var result = (!err && response.return.successful.localCompare("true") == 0) ?
response.return.payuReference : response.return.resultMessage;
cb(err, result);
});
};
Response:
SetTransaction: {"statusCode":500,"body":"<soap:Envelope xmlns:soap=\"http://sch
emas.xmlsoap.org/soap/envelope/\"><soap:Body><soap:Fault><faultcode xmlns:ns1=\"
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xs
d\">ns1:InvalidSecurityToken</faultcode><faultstring>An invalid security token w
as provided (An error happened processing a Username Token)</faultstring></soap:
Fault></soap:Body></soap:Envelope>","headers":{"date":"Tue, 17 Nov 2015 12:15:17
GMT","server":"Apache/2.4.12 (Win64) OpenSSL/1.0.2a mod_jk/1.2.40","x-distribut
ed-by":"AHC","content-length":"388","connection":"close","content-type":"text/xm
l;charset=UTF-8"},"request":{"uri":{"protocol":"https:","slashes":true,"auth":nu
ll,"host":"staging.payu.co.za","port":443,"hostname":"staging.payu.co.za","hash"
:null,"search":null,"query":null,"pathname":"/service/PayUAPI","path":"/service/
PayUAPI","href":"https://staging.payu.co.za/service/PayUAPI"},"method":"POST","h
eaders":{"User-Agent":"loopback-connector-soap/2.3.0","Accept":"text/html,applic
ation/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8","Accept-Encoding":"non
e","Accept-Charset":"utf-8","Connection":"close","Host":"staging.payu.co.za","Co
ntent-Length":1128,"Content-Type":"text/xml; charset=utf-8","SOAPAction":"\"\""}
}}
events.js:141
Thanks
Setting the security in datasources.json works, but you probably don't want to save username and password there.
There a couple of options:
1) You could use add a vairable which can be pulled from config.json and embed into datasources.json
like so: "security": ${security}.
And variable security is defined in config.env.json.
2) In a model, eg if you have a Product model, then you could use something like:
Product.datasources.settings.security = {'scheme':'WS', 'username':'abc'....}
I managed to resolve this by making use of the the connector's security option which creates the relevant SOAP Security header, provided that the relevant data is supplied.
security: {
scheme: 'WS',
username: "Staging Integration Store 3",
password: "WSAUFbw6",
passwordType: 'PasswordText'
},
XML conversion
<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Timestamp wsu:Id="Timestamp-2015-11-20T08:00:46Z">
<wsu:Created>2015-11-20T08:00:46Z</wsu:Created>
<wsu:Expires>2015-11-20T08:10:46Z</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-2015-11-20T08:00:46Z">
<wsse:Username>Staging Integration Store 3</wsse:Username>
<wsse:Password>WSAUFbw6</wsse:Password>
<wsu:Created>2015-11-20T08:00:46Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
I have a jsonp request to retrieve feature information via geoserver, the call looks something like this:
import Ember from 'ember';
export default Ember.Component.extend({
_selectParcel: function() {
function handleJson(data){
console.log(data);
}
$.ajax('url/geoserver/wms', {
type: 'GET',
data: {
service: 'WFS',
version: '1.1.0',
request: 'GetFeature',
typeName: 'name_here',
maxFeatures: 10000,
outputFormat: 'text/javascript',
srsname: 'EPSG:4326',
bbox: '-73.68229866027832, 40.97056664236637, -73.68229866027832, 40.97056664236637, EPSG:4326'
},
dataType: 'jsonp',
jsonpCallback: 'callback:handleJson',
jsonp: 'format_options'
});
}
});
The problem that I run into is dealing with the callback scope - in this case, handleJson()
I have also tried
.then(function(){});
after the ajax call but with no luck.
_selectParcel is going to be called frequently based on mouse movement.
How should the jsonp callback be handled within the Ember component?
I've seen this using ember data with jsonp but im not sure how to interact with an adapter from the component.
Console errors look like : "Uncaught ReferenceError: handleJson is not defined" the way its written above - and "Uncaught ReferenceError: parseResponse is not defined" when using callback=? and a ".then(function(){})" promise
Okay, so there are really 2 pieces here.
should ember components request data
how are geoserver jsonp requests handled
For the first one I found this write up helpful Should Components Load Data
For the second, this bit where the format_options and the jsonpCallback keys match did the trick. Thank you to this link
$.ajax('url/geoserver/wms', {
type: 'GET',
data: {
service: 'WFS',
version: '1.1.0',
request: 'GetFeature',
typeName: 'name_here',
maxFeatures: 10000,
outputFormat: 'text/javascript',
srsname: 'EPSG:4326',
bbox: '-73.68229866027832, 40.97056664236637, -73.68229866027832, 40.97056664236637, EPSG:4326',
format_options: 'callback:getJson'
},
dataType: 'jsonp',
jsonpCallback: 'getJson'
}).then(function(data) {
console.log(data);
});
Try changing this line:
jsonpCallback: 'callback:handleJson'
to
jsonpCallback: 'handleJson'
I'm just trying to test a very simple ajax call to a simple webservice. I'm using .net 4, iis 6. My webservice code looks like this...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Web.Script.Serialization;
namespace ABCNamespace {
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
public class MyService : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string HelloWorld()
{
return new JavaScriptSerializer().Serialize("Hello World");
}
}
}
My call looks like this
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "../../MyService.asmx/HelloWord",
data: "{}",
dataType: "json",
success: function () { alert('done'); },
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + errorThrown);
}
});
I'm keep getting 500 error and after taking a closer look, I'm getting a string back instead of json data. I think if correct this, it will fix my issue. However, I can't get it to return json data.
Here is a response check by invoking my webmethod
<?xml version="1.0" encoding="UTF-8"?>
<string xmlns="http://tempuri.org/"> "Hello World" </string>
Note: please ignore the fact that I'm using ../../ in my url instead of resolveURL. This is just for quick simple testing purposes. I also play around with the web.config handlers and no luck. Not sure what I miss...
i have a webservice whih has only one method in it
[WebMethod]
public string GetMovies()
{
using (var dataContext = new MovieCollectionDataContext())
{
var query = dataContext.Movies.Select(m =>new{m.Title,m.ReleaseDate}).Take(20);
var serializer = new JavaScriptSerializer();
return serializer.Serialize(query);
}
}
it serilize the object but when i get the result in firebug it look like this
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">[{"Title":"SQL","ReleaseDate":"\/Date(1224007200000)\/"},{"Title":"Termonator Salvation","ReleaseDate":"\/Date(1224007200000)\/"}]</string>
iam using Kendo and my jquery method is
var dataSource = new kendo.data.DataSource(
{
transport: {
read: {
type: "POST",
dataType: "json",
url: "/MovieService.asmx/GetMovies"
//contentType: "application/json; charset=utf-8",
}
},
change: function (e) {
alert(e);
},
error: function (e) {
alert(e[2]);
},
pageSize: 10,
schema: {
data: "d"
}
in the above jquery there is an error even when it calls i got this error
SyntaxError: JSON.parse: unexpected character
please help me to get the proper JSON plz i really neeed proper JSON to do my work
What exactly are you trying to parse? The whole response won't parse because it's XML, not json. If you are trying to parse just the value of the string element then you probably need to wrap it in quotes.
Update:
JSON.parse('[{"Title":"SQL","ReleaseDate":"\/Date(1224007200000)\/"},{"Title":"Termonator Salvation","ReleaseDate":"\/Date(1224007200000)\/"}]')
This blog post shows how to return JSON from an ASMX service: http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/
And here is a running project showing how to bind a Kendo Grid to an ASMX service: https://github.com/telerik/kendo-examples-asp-net/tree/master/grid-web-service-crud
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 );
}
});