After a few hours of research, i'm not able to parse a soap response.
I don't have used WSDL2OBJC or SudZc for parsing my WSDL file, I have used SoapUI which returns XML.
For an example of how it looks like :
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility- 1.0.xsd">
<s:Header>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis- open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="_0">
<u:Created>2013-01-25T12:19:59.906Z</u:Created>
<u:Expires>2013-01-25T12:24:59.906Z</u:Expires>
</u:Timestamp>
</o:Security>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<getAllEntitiesResponse xmlns="http://tempuri.org/">
<getAllEntitiesResult>
<Entity Id="2" Name="red" Hexa="#CD0000" Alpha="1" LastUpdated="2012-06-27T10:36:33.39">
<EntityKey>
/* Some code */
</EntityKey>
</Entity>
My question is : How can I parse this, just to have the "Entity" properties (Just the line with Entity id=2 name=red ...) ?
Thanks in advance,
Regards
Use the NSXML parser and then have the entities implement the NSCoding protocol. Insider initWithCoder, you will be able to get the properties out and populate the objects.
Related
I am trying to insert data into the SQL server database through SOAP XML Web service from IOS using Swift code, but it is get only Id value which is auto generate in database ,but i cant insert my data into table because it will get null values which i have passed in Soap message.
My Code in swift
<?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>
<CreateUserDetail xmlns='http://tempuri.org/'>
<userdetail>
<UserDetail>
<Id>1</Id>
<Username xsi:type='xs:string'>username</Username>
<Password xsi:type='xs:string'>password</Password>
</UserDetail>
</userdetail>
</CreateUserDetail>
</soap:Body>
</soap:Envelope>
I have surfing many of blog and sites and finally I got solution for it here is a soap message with solution
my new soap message is written below
<SOAP-ENV:Envelope xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:tns='http://tempuri.org/' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<tns:CreateUserDetail>
<tns:userdetail>
<tns:Id xmlns:tns='http://schemas.datacontract.org/2004/07/WcfService1'>1</tns:Id>
<tns:Username xmlns:tns='http://schemas.datacontract.org/2004/07/WcfService1'>String</tns:Username>
<tns:Password xmlns:tns='http://schemas.datacontract.org/2004/07/WcfService1'>String</tns:Password>
</tns:userdetail>
</tns:CreateUserDetail>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
you have to just replace xmlns:tns='your target namespace' which i have write in id,username,password element
hope it will help someone
I was to create XML as below and save it as a string. The values for the XML will be from sqlite database. I want to pass the string value which will be in a xml format through a WebService, so for that reason I want to create XML and save it as a string. Please help me with this.
1st XML:
<?xml version="1.0"?>
<EmployeeHeader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<EmplID>1001</EmplID>
<EmplName>Jack</EmplName>
<Designation>Manager</Designation>
<Department>Sales</Department>
</EmployeeHeader>
2nd XML:
<?xml version="1.0"?>
<EmployeeDetail xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Address>
<City>Philadelphia</City>
<State>PA</State>
<Country>USA</Country>
</Address>
</EmployeeDetail>
It's not completely clear what you're asking, but if I'm understanding you correctly, you just want to build an XML string substituting the values you get from a database?
Something like:
NSString *xml = [NSString stringWithFormat:#"<EmployeeDetail><Address><City>%#</City><State>%#</State><Country>%#</Country></Address>", addr.city, addr.state, addr.country];
I am trying to use ServiceStack to replace WCF for a self hosted service, accessed with a PHP client that forms its messages from on the WSDL.
The WSDL produced by ServiceStack has "part names" called "par" eg:
<wsdl:message name="GetServiceDetailsIn">
<wsdl:part name="par" element="tns:GetServiceDetails" />
</wsdl:message>
Then the SOAP request produced by PHP looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body><par/></SOAP-ENV:Body>
</SOAP-ENV:Envelope>
instead of this from the built-in help:
<?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>
<GetServiceDetails xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:Shout" />
</soap:Body>
</soap:Envelope>
The PHP client has used a par tag instead of GetServiceDetails and it gets a blank response. Can the "part name" definition can be renamed or removed in ServiceStack?
It seems you can't doing anything about this in ServiceStack and its not designed to work with PHP anyway. However you can get it working if you get PHP to tweak the XML tags with find-and-replace, or XSLTs, before sending it.
I'm getting a soap request like this:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<notifications xmlns="xxxxx">
<sometags></sometags>
<Notification>
<Id>yyyyy</Id>
<sObject xsi:type="sf:Dog" xmlns:sf="urn:some.enterprise.object.soap.com">
<sf:Id>zzzzz</sf:Id>
</sObject>
</Notification>
</notifications>
</soapenv:Body>
</soapenv:Envelope>
and I want to find out what kind of object is the notification about (== I want to read the sObject's type attribute, so
that I know whos type of sObject is related the id tag).
I want to be able to do something similar:
if (sObject.type.equals("Dog"))
//do something
if (sObject.type.equals("Cat"))
//do something else
but how can i get that attribute value in the soap request?
I'm using java with cxf libraries .
Thank you,
Cloutz
Just use Interceptor & do what ever you want.
I have used XmlSlurper successfully before, but am struggling to parse the following XML - it is a response from a call to the Pingdom API. I have tried following the namespace declaration examples, but I just get an error message on the ns1 and ns2 values. Can anybody help point me in the right direction? The xml looks like this:-
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:methods"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns2="urn:PingdomAPI"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:Auth_loginResponse>
<return xsi:type="ns2:Auth_LoginResponse">
<status xsi:type="xsd:int">0</status>
<sessionId xsi:type="xsd:string">mysessionId</sessionId>
</return>
</ns1:Auth_loginResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
after using the XmlSlurper it just concatenates the 0 and mysessionId to one string
0mysessionId
Try this, giving your xml is stored in the xml variable :
def records = new XmlSlurper().parseText(xml).declareNamespace(
'SOAP-ENV':'http://schemas.xmlsoap.org/soap/envelope/',
ns1:'urn:methods',
xsd:'http://www.w3.org/2001/XMLSchema',
xsi:'http://www.w3.org/2001/XMLSchema-instance',
ns2:'urn:PingdomAPI'
)
println records.'SOAP-ENV:Body'.'ns1:Auth_loginResponse'.return.status
println records.'SOAP-ENV:Body'.'ns1:Auth_loginResponse'.return.sessionId