1, the question throws: Now still have many people to useWSDL2OBJCcome off with webservice, but sometimes something unhappy happens,
<soap:envelope xmlns:soap= "http://schemas.xmlsoap.org/soap/envelope/" ><soap:Body><soap:Fault> <faultcode>soap:client</faultcode><faultstring>unmarshalling Error: Unexpected Element (URI: "// xxxxx.xxxxx.com/", Local:" a "). The required elements are <{}a>,<{}b>,<{}c> </faultstring></soap:fault></soap:body></soap: Envelope>
unexpected element, what a thing! Then look what we sent out.
<soap:Body> <xxxxService:test> <xxxxService:a>1</xxxxService:a> < xxxxservice:b>1.4</xxxxservice:b> <xxxxService:c>xxx</xxxxService:c> </ Xxxxservice:test> </soap:Body>
Here is a description: Xxxxservice is my servicename, here should be called namespace, this namespace is the culprit of the accident, now know the culprit, then we how to deal with it?
2, the solution: 1, Stupid way, (below there are clever ways Oh!) Find the corresponding setting parameter of the WebService method that you want to invoke, as follows:
-(void) Addelementstonode: (xmlnodeptr) node{if (SELF.A! = 0) {xmladdchild (node, [SELF.A Xmlnodefordoc:node->doc elementname:@ "A" elementnsprefix:@ "Xxxxservice"]);} if (self.b! = 0) {xmladdchild (node, [self.b xmlnodefordoc:node->doc elementname:@ "B" elementnsprefix:@ "XxxxService" ]);} if (SELF.C! = 0) {xmladdchild (node, [SELF.C xmlnodefordoc:node->doc elementname:@ "C" elementnsprefix:@ "XxxxService" ]);}}
Change the above Xxxxservice parameter to nil, and then complete the following
-(void) Addelementstonode: (xmlnodeptr) node{if (SELF.A! = 0) {xmladdchild (node, [SELF.A Xmlnodefordoc:node->doc elementname:@ "a" elementnsprefix:nil]);} if (self.b! = 0) {xmladdchild (node, [self.b xmlnodefordoc:node->doc elementname:@ "B" elementnsprefix:nil]);} if (SELF.C! = 0) {xmladdchild (node, [SELF.C xmlnodefordoc:node->doc elementname:@ "C" Elementnsprefix:nil]);}}
Why is this method stupid? Because this webservice has a lot of methods, it is not to get rid of, of course, smart points do not go back to the manual, replace with the text, all replaced, but if the interface has changed it? and replace it again, so there's a smarter way.
2, clever way: Gossip not much to say, is oneself change WSDL2OBJC of source code, customize a own WSDL2OBJC.
First, Source: Open http://code.google.com/p/wsdl2objc/
Click Export to GitHub, then click, then click on the bottom of the green button, here default everyone has GitHub account, not to register a bar! The way to get the source code is more than this one, but also useful for SVN, personally prefer GitHub. Then you have a copy of your own source code on your GitHub account. If you can't get it, just use mine. HTTPS://GITHUB.COM/BABYDANCE/WSDL2OBJC,
Select Download Zip download to get the source done.
Second, open the project file with Xcode. It's possible that Xcode will prompt you if you want to turn the project into arc.
The template file in the red box is where we're going to change it.
Use Search to find the place we're going to change. Search term: Xmlnodefordoc:node->doc elementname:
Found two places, we just change the first one.
The red box is where we're going to change, yes, to nil,
After the change is done, Cmmand plus R run. Re-generate it and look at it.
-(void) Addelementstonode: (xmlnodeptr) node{if (SELF.A! = 0) {xmladdchild (node, [SELF.A Xmlnodefordoc:node->doc elementname:@ "a" elementnsprefix:nil]);} if (self.b! = 0) {xmladdchild (node, [self.b xmlnodefordoc:node->doc elementname:@ "B" elementnsprefix:nil]);} if (SELF.C! = 0) {xmladdchild (node, [SELF.C xmlnodefordoc:node->doc elementname:@ "C" Elementnsprefix:nil]);}}
Is it the nil that was generated?
Take out the app file and give it to a family, duang~~~~,
WSDL2OBJC namespace Custom