I am working on a project where I required to parse XML response coming from web service. I don't know anything about the structure of response. I am given XML elements to gather data for, and the data is relational so elements represents columns in relational table.
I tried the WSDL approach where I can parse for method name and its response type. Based on that I can parse with NSXMLParser. The problem was I didn't find any WSDL parser which does this for me.
Any suggestions?!
Thanks,
Jignesh
I like to use this OpenSource library on GitHub
It will allow you to turn the XML string into an NSDictionary which you can the use dynamically.
Related
I'm using KissXML on iOS to parse the XML data returned from a wcf REST web service (written in c#)
The trouble I have is that KissXML doesn't like the namespace in the XML data that I get from the web service.
In a trivial example the XML data I get looks like this:
<ArrayOfItem xmlns="http://schemas.datacontract.org/2004/07/DataUpdateService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Item>Test</Item></ArrayOfItem>
KissXML can't seem to use xpath to parse this XML
resultNodes = [xmlDoc nodesForXPath:#"//Item" error:&error];
If I remove the default namespace from the XML string - then it works fine.
<ArrayOfItem xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Item>Test</Item></ArrayOfItem>
So this XML is fine and using the objective-c above I get 1 object in my array (as expected).
So the question is: What should I be doing about this? I have control of both the service and the iOS app so I can either change the service to try to remove or change the namespace (pointers to how to do this appreciated), or I can rip it out of my string once I get the data to the phone.
Both of these options feel a bit like a hack - are there better options?
I would recommend changing the defaultOutgoingResponseFormat to Json,
and handling it instead of xml.
Why? read here:
http://www.json.org/xml.html
and also it will solve your problem :)
I'm getting a JSON response after accessing a web service with my window application written in VB.NET. How can I convert the JSON response to a VB.NET object and vice versa? Any help will be appreciated! Thanks!
You may want to take a look at PW.JSON. As far as I know, it is the only library to serialize / deserialize JSON objects in VB.net. JSON.org lists a number of different libraries for JSON serialization at the bottom of the page, but unfortunately, PW.JSON appears to be the only one for VB.net.
I need to make a large number of SOAP test cases to automate the testing process of an application.
Currently, the architecture requires that a single "generic" SOAP method is invoked with an object of a generic type. Each "real" operation is defined by an element in the generic object and requires an object of an extended type to be used as input.
When I create the request template with soapUI, I only get the generic object elements, but I would like to add the empty template for a specific XSD type that is defined in my current schema to be used.
If I use xsi:type then soapUI correctly says that my markup is not valid against the schema (missing required elements), but I can't manage to get a ready-to-fill XML template.
Can you help me?
Example
genericRequest is made of
<genericRequest>
<methodName>specificMethodName</methodName>
<authenticationID>ABCDEF</authenticationID>
</genericRequest>
sumReuqest (extending genericRequest) for a "sum" operation is made of
<sumRequest>
<methodName>specificMethodName</methodName>
<authenticationID>ABCDEF</authenticationID>
<addend>5</addend>
<addend>3</addend>
</sumRequest>
I would ultimately like soapUI to fill a SOAP template with empty addend item (of course I work with lots of elements, and they are structured too!!)
In this case you need to create two resources in soaupUI one for generic request and other for operation request, I know right now its pain to create each resource for each operation, but soapUI is developed like that or if you think any of the parameters listed : http://www.soapui.org/REST-Testing/understanding-rest-parameters.html could help, you could define parameters as one of the above.
you could try using QUERY or MATRIX style parameters in your resource.
So here's the problem - I have a DataTable I want WCF (.NET 3.5) to send out in a JSON store format commonly used in ExtJS, etc - basically "Rows[{"Field1":value,"Field2":value},{...}]" but I cannot find the right structure to feed back to the Operation contract to send it out in this format.
So any ideas, or any further info needed.
Thanks, in advance!
AndyPC, unfortunately, you're out of luck.
If you're dealing with an object whose type is an IXmlSerializable, the WCF JSON serializer delegates to IXmlSerializable methods first, gets the serialized XML out of them, wraps the XML in a JSON string, and just passes that on. This is one of the major weaknesses of the WCF JSON model in .NET 3.5. I think the entity framework (WCF Data Services) technologies try to handle this more elegantly, but not sure. I'd recommend manually using the JSON serializer and crafting up a string or a manual serialization mechanism that does what you want...
I am working on a project in which a server page is called through XMLHttp and now I want to retrieve response the called page in json object.
and I never used json so I don't have any idea about it so please tell me how I can make json object in my server side vb.net page.
You can use JSON.NET or use DataContractJsonSerializer built in .NET 3.5.
It isn't too clear what you need to do, as far as I can understand you want to send to the caller JSON responses from a webserver, using VB.NET. I suggest to take a look at JSON.NET project, which makes serializing and deserializing your .NET objects to JSON a breeze!