Namespace in SOAP in Rails - ruby-on-rails

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>

Related

IBM BUS Change Soap Namespace of Responce

My Soap Responce like
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<Response xmlns="http://tempuri.org/">
<Result>
<Result>LOGON FAILED</Result>
</Result>
</Response>
</soapenv:Body>
</soapenv:Envelope>
But, I need change the prefix of namespace and responce and must like this one.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<Response xmlns="http://tempuri.org/">
<Result>
<Result>LOGON FAILED</Result>
</Result>
</Response>
</soapenv:Body>
</soap:Envelope>
If you are using ESQL to construct your message you can do this as described here:
https://www.ibm.com/support/knowledgecenter/SSKM8N_8.0.0/com.ibm.etools.mft.doc/ac67194_.htm
DECLARE soapNs NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
DECLARE tempNs NAMESPACE 'http://tempuri.org/';
SET OutputRoot.XMLNSC.soapNs:Envelope.(XMLNSC.NamespaceDecl)xmlns:soap = soapNs;
SET OutputRoot.XMLNSC.soapNs:Envelope.soapNs:Body.tempNs:Response.(XMLNSC.NamespaceDecl)xmlns = tempNs;
SET OutputRoot.XMLNSC.soapNs:Envelope.soapNs:Body.tempNs:Response.tempNs:Result.tempNs:Result = 'LOGON FAILED';
But still, the value of the namespace tags shouldn't make a difference.

How to convert string to xml in iOS? (objective C, xcode 7.2)

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

Using Servicestack WSDL with php

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.

cxf - parsing soap messages element's attribute

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.

Using XmlSlurper in Groovy / Grails to parse a Pingdom XML response

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

Resources