Comments (11)
+1 for this too. We need to be able to send raw XML to our server (old API) and do need the requests to NOT be serialized. Sent as raw.
from cordova-plugin-advanced-http.
This method is wrong, but work
I use this.http.setDataSerializer('json');
let headers = {
"Content-type": 'text/xml;charset="utf-8"',
"Accept": "text/xml",
};
let xml = 'Xml content as string';
this.http.post(soapUrl, xml, headers).then( .... ).catch(...)
For iOS
I am edit AFURLRequestSerialization.m file
/plugins/cordova-plugin-advanced-http/src/ios/AFNetworking
/node_modules/cordova-plugin-advanced-http/src/ios/AFNetworking
if (parameters) {
if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) {
[mutableRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
}
//Comment this row
//[mutableRequest setHTTPBody:[NSJSONSerialization dataWithJSONObject:parameters options:self.writingOptions error:error]];
//Add this row
[mutableRequest setHTTPBody: [parameters dataUsingEncoding:NSUTF8StringEncoding]];
}
from cordova-plugin-advanced-http.
- 1 for this, due to the new introduced ' cordova-plugin-ionic-webview ', it enforces CORS which the previous plugin doesn't, and we couldn't able to configure at api side, we couldn't use http from angular to call soap api anymore
from cordova-plugin-advanced-http.
I'm solved (maybe is wrong method)
With this.http.setDataSerializer('json');
let headers = {
"Content-type": 'text/xml;charset="utf-8"',
"Accept": "text/xml",
"Pragma": "no-cache",
"SOAPAction": http://*.com/ws/card/getCard,
};
let xml = '<?xml version="1.0" encoding="UTF-8"?>' +
'<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" '+
'xmlns:ns1="'+_namespace_+'"'+
' xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="'+_namespace_+'">'+
'<SOAP-ENV:Header><ns2:UserCredentials>'+
'<xsd:string>'+_username_+'</xsd:string>'+
'<xsd:string>'+_password_+'</xsd:string>'+
'</ns2:UserCredentials></SOAP-ENV:Header>' +
'<SOAP-ENV:Body><ns1:'+_service_+'>'+_paramsxml_+
'</ns1:'+_service_+'>' +
'</SOAP-ENV:Body></SOAP-ENV:Envelope>
this.http.setDataSerializer('json');
this.http.post(soapurl, xml , headers).then( .... ).catch(...)
from cordova-plugin-advanced-http.
Don't know why, but this.http.setDataSerializer('json');
allows sending XML but uses 'content-type': 'application/json; charset=UTF-8',
and it can't be overridden by a custom header 'Content-Type': 'application/xml; charset=utf-8'
from cordova-plugin-advanced-http.
Same issue here. Which version of the plugin are you using @iligzar? Your solution doesn't work for me on Android, I get an error with status 415, trying to make a call like you do. I am using plugin version 1.9.1 and ionic native version 4.5.2
http.setDataSerializer('json'); //bodyRequest is a string that contains xml http.post(url ,bodyRequest, {"SOAPAction": soapaction, "Pragma": "no-cache","Content-Type": "text/xml; charset=utf-8", "Accept": "text/xml"}).then((response) => { SOAPClient._onSendSoapRequest(isBrowser, method, async, callback, wsdl, xmlHttp); }).catch(e => { })
from cordova-plugin-advanced-http.
@jondediego
u shouldnt set 'http.setDataSerializer('json')' and '"Content-Type": "text/xml; charset=utf-8"' at the same time . its doesnt make sense.
from cordova-plugin-advanced-http.
Ok @Steve720zhang, so is there currently a way to send raw XML to a server with a NOT serialized body request?
from cordova-plugin-advanced-http.
Hi guys,
upcoming version 1.10.0 will support a new serializer utf8
, which should solve your problem.
e.g. without ionic-native wrapper:
http.setDataSerializer('utf8');
http.setHeader('text/xml; charset=utf-8');
http.post(url, xmlString, additionalHeaders, successHandler, failHandler);
e.g. with ionic-native wrapper:
this.http.setDataSerializer('utf8');
this.http.setHeader('text/xml; charset=utf-8');
this.http.post(url, xmlString, additionalHeaders)
.then(...)
.catch(...)
Basically this "serializer" is just a feature which is passing your string as plain text to the server. So I could have called it plain
, text
or none
, but I've decided to call it utf8
, because it only supports this encoding.
Please check if this feature fits your needs!
from cordova-plugin-advanced-http.
this.http.setHeader('text/xml; charset=utf-8');
Typescript highlight the above code as error 'Expected 2 arguments, but got one'
from cordova-plugin-advanced-http.
The documentation says:
setHeader(host, header, value)
Set a header for all future requests. Takes a hostname, a header and a value.
Param | Type | Details |
---|---|---|
host | string | The hostname to be used for scoping this header |
header | string | The name of the header |
value | string | The value of the header |
from cordova-plugin-advanced-http.
Related Issues (20)
- Can't set name to file when sending FormData HOT 3
- Is this repo still maintained? HOT 2
- [Bug] An SSL error has occurred and a secure connection to the server cannot be made HOT 1
- [Bug] Apparent bug in serializeArray() HOT 1
- [[__NSArrayM insertObject:atIndex:]: object cannot be nil] [Cordova-Ios] App crash with SSL pinned active HOT 4
- How do I make downloaded files viewable in the iPhone's Files and Photos apps? HOT 1
- [Bug] sendRequest doesn't contain success/failure types HOT 1
- [Bug] [platform] deviceready has not fired after 5 seconds HOT 1
- documentation issue - broken link
- Pinned certificate works on Android but not iOS HOT 1
- [Bug] [android] cordova-plugin-file dependency installs version incompatible with cordova-android on Meteor
- Is there a new release planned? HOT 1
- HttpResponseType blob type empty data, even though the request is successful
- Dynamic Data
- [Bug] [Android] TLS connection could not be established: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. HOT 5
- uploadFIle doesn't send parameters
- [Bug] SSL pinning is not working for both iOS and Android HOT 3
- BSF Cordova Ecosystem Crowdfunding Plan
- Android & iOS Certificate Pinning
- [Android] No installed provider supports this key: com.android.org.bouncycastle.jcajce.PKCS12Key HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-advanced-http.