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.
Related
I want to convert a NSString variable containing xml codes into xml format. My xml request is:
<?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>
<Authentication xmlns="(namespace link)">
<Credentials>
<Username>username</Username>
<Password>password</Password>
</Credentials>
</Authentication>
</soapenv:Body>
</soapenv:Envelope>
then i saved this request to a NSString variable. And i got response for this as the server didn't recognize as xml. So how to convert the string i saved into xml?
Simple code for SOAP request and parsing.
Goto the link: https://yuvarajmanickam.wordpress.com/2012/10/17/soap-message-request-and-xmlparsing-in-ios-app/
or
github.com/nicklockwood/XMLDictionary
or
stackoverflow.com/questions/803676/encode-nsstring-for-xml-html
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.
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.
I'm using the Savon gem to interact with a WSDL. For some reason, Savon is using env as a namespace instead of soapenv.
How do I make Savon generate requests with the soapenv namespace, rather than the env namespace?
Savon.config.env_namespace = :soapenv
There is a special property for this:
Savon.env_namespace = :soapenv
With this property set Savon will generate requests like this:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsdl="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<wsdl:sayHello></wsdl:sayHello>
</soapenv:Body>
</soapenv:Envelope>
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