kodlian / alamofirexmlrpc Goto Github PK
View Code? Open in Web Editor NEWAlamofireXMLRPC brings XML RPC functionalities to Alamofire
License: MIT License
AlamofireXMLRPC brings XML RPC functionalities to Alamofire
License: MIT License
I am trying to use the protocol XMLRPCRequestConvertible, but I am asked to implement the asUrlRequet() function, which is not in the protocol. I found tha it is defined in an extension of the protocol. how to use the function that you write and not have to rewrite it ?
I need a app to iPhone 5, but when I build the code many errors occurrs. In the Readme informs that works in iOS > 9, I'm using iOS 10.3.1 on iPhone.
The erros are like:
Module 'AlamofireXMLRPC' has no member named 'request'
I can use this framework on iPhone 5C?
The readme indicates iOS version 8.0+ is required, while the podspec file indicates 9.0.
I'm trying get download progress of a request but the variable totalUnitCount
is -1.
AlamofireXMLRPC.request(OdooAuth.host2!, methodName: "execute_kw", parameters: params).responseXMLRPC {
(response: DataResponse<XMLRPCNode>) -> Void in
switch response.result {
case .success(_ ):
break
case .failure(let err):
break
}.downloadProgress { (progress) in
print("PROGRESS: \(Float(progress.completedUnitCount)) - \(Float(progress.totalUnitCount))")
}
*OUTPUT
...
PROGRESS: 1012226.0 - -1.0
PROGRESS: 1017048.0 - -1.0
PROGRESS: 1128709.0 - -1.0
PROGRESS: 1133445.0 - -1.0
PROGRESS: 1242951.0 - -1.0
PROGRESS: 1253212.0 - -1.0
PROGRESS: 1354533.0 - -1.0
PROGRESS: 1369654.0 - -1.0
PROGRESS: 1397373.0 - -1.0
PROGRESS: 1397760.0 - -1.0
PROGRESS: 1467853.0 - -1.0
PROGRESS: 1468243.0 - -1.0
PROGRESS: 1538378.0 - -1.0
...
I'm trying to use AlamofireXMLRPC inside a background fetch.
My requests work fine if they're triggered while the app is active or it's state is changed to active, but when I trigger them inside a background fetch it seems like the execution stops as soon as the first request is being made.
If i then activate my app, the requests are processed as expected in the active state. If I activate the app too late i get a timeout error.
So is there any known issue with AlamofireXMLRPC regarding using it for background fetch?
Hi, i'm trying to reach the service API with this lib, and i see using response.data
that response returns as xml. But, XMLRPCNode says
FAILURE: fault(node:
)
Here is real response:
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<fault>
<value><struct>
<member><name>faultCode</name>
<value><i4>-506</i4></value></member>
<member><name>faultString</name>
<value><string>Method 'one.user.show' not defined</string></value></member>
</struct></value>
</fault>
</methodResponse>
I'm really new to swift(like second day), so maybe i'm missing some debug options, but how could i fix this?
P.S. I'm using totally same "structure" as in example provided:
let data: NSData = ...
let params: [Any] = [42, "text", 3.44, Date(), data]
AlamofireXMLRPC.request("http://localhost:8888/xmlrpc", methodName: "foo", parameters: params).responseXMLRPC { (response: DataResponse<XMLRPCNode>) -> Void in
switch response.result {
case .success(let value):
if let message = value[0].string, age = value[1]["age"].int32 {
...
}
case .failure:
...
}
There's an issue I've been dealing with for the last 3-4 days, and no matter how I try to construct my method in Swift syntax, I'm getting errors.
The method is part of the WP XMLRPC API and is called wp.newPost. The documentation states that we need to pass the following in the method parameters: (WordPress uses PHP)
I'm 100% certain that the problem lies in the way I'm passing the struct content
part, as all other paramters I've passed worked with other methods.
When I check my server logs, this is the PHP error I'm seeing:
Cannot unset string offsets in /nas/content/live/sitename/wp-includes/class-wp-xmlrpc-server.php on line 1212
These are the lines referenced:
1209: /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
1210: do_action( 'xmlrpc_call', 'wp.newPost' );
1211:
1212: unset( $content_struct['ID'] );
1213:
1214: return $this->_insert_post( $user, $content_struct );
My question is: How can I see the XMLRPC request that I'm sending, and possible see how things are getting passed?
Code snipper from the method:
let myInfo:[String: String] = ["post_title": "Hi there", "post_content": "Hello"]
let headeros = ["User-Agent": "xApp"]
let params: [Any] = [0, "\(WP_USERNAME)", "\(WP_PASSWORD)", myInfo]
AlamofireXMLRPC.request("\(WP_URL)", methodName: "wp.newPost", parameters: params, headers: headeros).responseString {
(response:Response<String, NSError>) -> Void in
guard response.result.isSuccess else {
print("Error in clause response isSucess for wp.newPost method")
print(response.result.error)
return
}
let davalue = response.result
print(davalue)
response.result.value
prints:
Optional("")
response.result
prints:
SUCCESS
po response
prints:
[Request]: <NSMutableURLRequest: 0x7ffa40516cc0> { URL: http://websiteurl.com/xmlrpc.php }
[Response]: <NSHTTPURLResponse: 0x7ffa40704a80> { URL: http://websiteurl.com/xmlrpc.php } { status code: 500, headers {
Connection = "keep-alive";
"Content-Length" = 0;
"Content-Type" = "text/html";
Date = "Thu, 24 Dec 2015 14:35:10 GMT";
"Keep-Alive" = "timeout=20";
Server = nginx;
} }
[Data]: 0 bytes
[Result]: SUCCESS:
▿ request : Optional(<NSMutableURLRequest: 0x7ffa40516cc0> { URL: http://websiteurl.com/xmlrpc.php })
▿ response : Optional(<NSHTTPURLResponse: 0x7ffa40704a80> { URL: http://websiteurl.com/xmlrpc.php } { status code: 500, headers {
Connection = "keep-alive";
"Content-Length" = 0;
"Content-Type" = "text/html";
Date = "Thu, 24 Dec 2015 14:35:10 GMT";
"Keep-Alive" = "timeout=20";
Server = nginx;
} })
▿ data : Optional(<>)
▿ result : SUCCESS:
- Success : ""
You can also see that the headers I've specified were NOT passed.
When the control character is included in the XML, the parsing will fail. Need to filter out the control characters before parsing.
I'm using a Odoo service. When I trying log in, I receive the follow errror:
Auth Error
error The operation couldn’t be completed. (AlamofireXMLRPC.XMLRPCError error 2.)
Looking the error, of XMLRPCError. The error is: "parseFailed". But I don't know where I'am going wrong.
AlamofireXMLRPC.request(self.host, methodName: "authenticate", parameters: paramsAuth).responseXMLRPC { (response: DataResponse<XMLRPCNode>) -> Void in switch response.result { case .success(let value): print("Auth Success") var str = String(data: response.data!, encoding: String.Encoding.utf8) as String! print(str) break case .failure(let error): print("Auth Error") print("error \(error.localizedDescription)") break }
The other methods of API odoo works fine: https://www.odoo.com/documentation/11.0/webservices/odoo.html.
@kodlian When will you update the lib for next version of ios?
New release needs to be made for cocoapods to get master repo
HI,
This is not a bug, I'm pretty new to Swift and AlamofireXMLRPC so I'm sure there's something wrong that I'm doing.
I have the following AFXMLRPC request:
AlamofireXMLRPC.request("\(WP_URL)", methodName: "wp.getTerms", parameters: params).responseXMLRPC { (response:Response<XMLRPCNode, NSError>) -> Void in
guard response.result.isSuccess else {
print(response.result.error)
return
}
let davalue = response.result.value![0][0]["name"].string!
print(davalue)
} // End Alamofire request
The above code block works perfectly, and by that I mean that it gets me the first category in my site. As expected, assigning devalue
the following:
response.result.value![0][1]["name"].string!
Gives me the 2nd category.
What I actually want is to iterate through my list of categories.
However, writing this:
let davalue = response.result.value![0]
for item in davalue {
….
}
Gives an error "Type 'XMLRPCNode" does not conform to protocol "SequenceType""
Is there any non-convoluted way to iterate through the values I'm getting inside the XMLRPCNode?
Thanks!
i'm getting this error: nodeNotFound(AlamofireXMLRPC.XMLRPCNodeKind.methodResponse)
This my code:
func getListOfDatabasesTest(){
let user = "username"
let password = "paassword"
let url = "http://195.112.209.206:1005/AndroidGlobalWebService/Service1.asmx"
let credentialData = "\(username):\(password)".data(using: String.Encoding(rawValue: String.Encoding.utf8.rawValue))!
let base64Credentials = credentialData.base64EncodedString()
let headers = [
"Authorization": "Basic \(base64Credentials)",
"Accept": "application/json"
]
let param:[Any] = [ user,password,"sdfghjkl","L"]
AlamofireXMLRPC.request(url, methodName: "AdminAuthenticationNew", parameters: param, headers: headers).responseXMLRPC { (response: DataResponse<XMLRPCNode>) -> Void in
switch response.result {
case .success(let value):
print("success: \(value)")
case .failure(let value):
print("error: \(value)")
}
}
}
Hello,
For one of my XMLRPC methods, I'm getting a really weird error:
Optional(Error Domain=net.tadija.AEXML Code=1 "(null)")
Any way to get anything more descriptive? What does this basically mean?
my response (odoo)
<methodResponse>
<params>
<param>
<value>
<array>
<data>
<value>
<struct>
<member>
<name>id</name>
<value>
<int>21</int>
</value>
</member>
<member>
<name>name</name>
<value>
<string>Akbar</string>
</value>
</member>
<member>
<name>login</name>
<value>
<string>[email protected]</string>
</value>
</member>
<member>
<name>partner_id</name>
<value>
<array>
<data>
<value>
<int>258</int>
</value>
<value>
<string>Akbar</string>
</value>
</data>
</array>
</value>
</member>
<member>
<name>company_ids</name>
<value>
<array>
<data>
<value>
<int>1</int>
</value>
</data>
</array>
</value>
</member>
<member>
<name>company_id</name>
<value>
<array>
<data>
<value>
<int>1</int>
</value>
<value>
<string>PT. Comp</string>
</value>
</data>
</array>
</value>
</member>
<member>
<name>env_company_id</name>
<value>
<array>
<data>
<value>
<int>1</int>
</value>
<value>
<string>PT. Comp</string>
</value>
</data>
</array>
</value>
</member>
<member>
<name>company_employee_id</name>
<value>
<int>39</int>
</value>
</member>
<member>
<name>employee_ids</name>
<value>
<array>
<data>
<value>
<int>39</int>
</value>
</data>
</array>
</value>
</member>
<member>
<name>employee_id</name>
<value>
<int>39</int>
</value>
</member>
<member>
<name>clearing_residuals_sum</name>
<value>
<double>0.0</double>
</value>
</member>
<member>
<name>partner_mobile</name>
<value>
<string>+62 823</string>
</value>
</member>
<member>
<name>partner_email</name>
<value>
<string>[email protected]</string>
</value>
</member>
<member>
<name>partner_street</name>
<value>
<string>Street RT.001/RW.001</string>
</value>
</member>
<member>
<name>partner_street2</name>
<value>
<string>My District</string>
</value>
</member>
<member>
<name>partner_city</name>
<value>
<string>Gowa</string>
</value>
</member>
<member>
<name>partner_state_id</name>
<value>
<array>
<data>
<value>
<int>63</int>
</value>
<value>
<string>Sulawesi Selatan</string>
</value>
</data>
</array>
</value>
</member>
<member>
<name>partner_country_id</name>
<value>
<array>
<data>
<value>
<int>100</int>
</value>
<value>
<string>Indonesia</string>
</value>
</data>
</array>
</value>
</member>
<member>
<name>mobile_app_last_version</name>
<value>
<string>2.9</string>
</value>
</member>
<member>
<name>mobile_app_last_version_url</name>
<value>
<string>https://dre.google.com/uc?export=download&id=myid</string>
</value>
</member>
</struct>
</value>
</data>
</array>
</value>
</param>
</params>
</methodResponse>```
For one of my XMLRPC methods, I'm getting a really weird error:
Optional(Error Domain=com.kodlian.XMLRPC.error Code=1 "Error Unknown" UserInfo={NSLocalizedFailureReason=Error Unknown})
Any way to get anything more descriptive? What does this basically mean?
I'm use AlamofireXMLRPC but i don't how convert xml data to json data or Object
you can help me please
Alamofire 5.0 introduced a number of breaking API changes that make it incompatible with AlamofireXMLRPC. This mainly impacts XMLResponseSerializer
and XMLRPCResponseSerializer
.
In order to support the 5.0 API and maintain consistency, breaking changes must be introduced here. Serialization functions now throw instead of returning a result type.
I have a branch with the necessary changes. I'll submit a PR and see what everyone thinks.
If you iterate through the Arrays in a very big Response (in my case over 300 arrays you get after the second "child array" only 300 copies of one but not 300 different arrays.
Looks as if only the first one is simply copied 300 times.
This is the function i use:
func iterateNode(currentNode: [XMLRPCNode], durchgang: Int) {
print("----- Anfang des Nodes: \(durchgang) -----")
for everynode in currentNode {
if let anzahl = everynode.count {
print(anzahl)
} else
{
print("keine Unterknoten zum zählen")
}
if let dict = everynode.dictionary {
print("Anzahl der Einträge: \(dict.count)")
for everdict in dict {
let dictString = everdict.0
if let value = everdict.1.string {
print("\(dictString): \(value)")
}
}
}
if everynode.count > 0 {
let neueAnzahl = durchgang + 1
print("--- Ende des Nodes: \(durchgang) ----")
let testnode = everynode.array!
self.iterateNode(testnode, durchgang: neueAnzahl)
}
else {
print("--- Ende des Nodes ----")
}
}
}
Xcode 8 and Swift 3 are now out, but this has yet to be updated to Swift 3. Could you please do so? Thank you. :)
I need to maintain sequential response result. In my case first response result leads second request and so on. how can I achieve that ? I'm very new with swift/iOS. I'm familiar with AsyncTask from android. I'm don't know why Alarmfire not comes with non async support out of the box.
I'm looking for something similar:
let firstResponse= requestFirst.responseXMLRPC()
if firstResponse.result == "success" {
let val = firstResponse.value
let uid : Int32 = getUID(val: val)
let requestSecond=AlamofireXMLRPC.request(formattedURL("xmlrpc/2/object"), methodName: "execute_kw", parameters: [uid])
let secondResponse= requestSecond.responseXMLRPC()
if secondResponse.result == "success" {
.........
}
}
please ignore syntax error. I'm from java/Android. 2 days experience in swift
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.