Is it correct that a namespace prefix in a soap request be fixed? - soap

When calling a web service, the client is expected to send a specific prefix for a namespace. Otherwise, a fault code is returned.
Here's the request that returns a fault code:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.connector.uut.cs.com.tr/">
<soapenv:Header>
<se:Security xmlns:se="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<se:UsernameToken>
<se:Username>XXXX</se:Username>
<se:Password>XXXX</se:Password>
</se:UsernameToken>
</se:Security>
</soapenv:Header>
<soapenv:Body>
<ser:kayitliKullaniciListeleExtended>
<urun>EFATURA</urun>
<gecmisEklensin></gecmisEklensin>
</ser:kayitliKullaniciListeleExtended>
</soapenv:Body>
</soapenv:Envelope>
Whereas this request works:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.connector.uut.cs.com.tr/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>XXXX</wsse:Username>
<wsse:Password>XXXX</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ser:kayitliKullaniciListeleExtended>
<urun>EFATURA</urun>
<gecmisEklensin></gecmisEklensin>
</ser:kayitliKullaniciListeleExtended>
</soapenv:Body>
</soapenv:Envelope>
Only difference between the two requests is the namespace prefix (the one that works is wsse, every other prefix fails). Is it a correct implementation to ask the client to pass a specific prefix for the namespace?
I expected that the prefix names can be anything as long as the uri identified by xmlns: is correct.

Related

Change Namespace URI in Spring SOAP WS

We have some legacy systems that consume the same #Endpoint however each with a different namespace. The payload, implementation and functionality are the same except for the namespace of the SOAPBody's first child element.
How would I replace the namespace of the incoming SOAP request to a generic one before it reaches the Endpoint? Tried playing with the EndpointInterceptor however unable to find a method to replace the namespace.
Legacy System 1:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<GetRecordsRequest xmlns="http://www.test.com/system1">
<maxRecords>100</maxRecords>
<GetRecordsRequest>
</soapenv:Body>
</soapenv:Envelope>
Legacy System 2:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<GetRecordsRequest xmlns="http://www.abctest.com/system2">
<maxRecords>100</maxRecords>
<GetRecordsRequest>
</soapenv:Body>
</soapenv:Envelope>

How to add the custom security tag in all request in soapUi using groovy

I have to insert the security tag in all the request inside the header. How do I automate? because for every request I have to copy past manually which takes time to do for all the request
Below is the Actual Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ws="http://ws.test.sample.com/" xmlns:ws1="http://ws.test.sample.com/">
<soapenv:Header>
</soapenv:Header>
After adding the security tag:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ws="http://ws.test.sample.com/" xmlns:ws1="http://ws.test.sample.com/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://doc.test.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="http://doc.test.xsd">
<wsse:Username>test</wsse:Username>
<wsse:Password Type="http://doc.test.xsd">o9j1/hA/mkFTG0ODti</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>

WSO2 Identitiy Server Password change, getting issue “Can not access the directory service for user”

I am attempting a password reset feature in wso2 identity server where I'm using LDAP as secondary storage.
I'm using this( https://docs.wso2.com/display/IS530/Configuring+Users#ConfiguringUsers-UpdateuserusingSOAP) link as documentation to update user details by calling https://localhost:9443/services/RemoteUserStoreManagerService?wsdl admin service.
I'm using LDAP as secondary storage. but, when I'm trying to update the password by the updateCredential() method getting the below issue
getting this error response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>Can not access the directory service for user : yellow#xyz.com</faultstring>
<detail/>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
where I'm sending this request to updateCredential() method
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.ws.um.carbon.wso2.org">
<soapenv:Header/>
<soapenv:Body>
<ser:updateCredential>
<!--Optional:-->
<ser:userName>USERS/yellow#xyz.com</ser:userName>
<!--Optional:-->
<ser:newCredential>123456</ser:newCredential>
<!--Optional:-->
<ser:oldCredential>123456789</ser:oldCredential>
</ser:updateCredential>
</soapenv:Body>
</soapenv:Envelope>

SOAP The root element for the request could not be determined

I'm getting the following error when I try and post some SOAP requests:
<?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://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Receiver</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text>The root element for the request could not be determined. When RoutingStyle is set to RequestElement, SoapExtensions configured via an attribute on the method cannot modify the request stream before it is read. The extension must be configured via the SoapExtensionTypes element in web.config or the request must arrive at the server as clear text.</soap:Text>
</soap:Reason>
</soap:Fault>
</soap:Body>
I'm using
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:m="http://test.#######.co.uk/ws-b/>
<soapenv:Body>
<hs:logon>
<hs:username>USER</m:username>
<hs:password>pass123</m:password>
</hs:logon>
</soapenv:Body>
</soapenv:Envelope>
However, I can get some request to work using messages of a similar format. What does this mean?
"hs" namespace doesn't seem to be declared. Also you closing tags are with different namespace than openings. Can you try:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:hs="http://test.#######.co.uk/ws-b/">
<soapenv:Body>
<hs:logon>
<hs:username>USER</hs:username>
<hs:password>pass123</hs:password>
</hs:logon>
</soapenv:Body>
</soapenv:Envelope>
This is what I finally got to work:
<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope">
<Body>
<logon xmlns="http://tempuri.org/">
<username>user</username>
<password>password</password>
</logon>
</Body>
</Envelope>

Missing wsse:Security header in request

I try to add rampart security to my axis 2 project using this tutorial page 19- 22
SO everything seems fine but when I switch to soapUI perspective to try to test the service
the request which I'm proposed is :
soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:axis="http://axis2wstest">
<soapenv:Header/>
<soapenv:Body>
<axis:testws>
<!--Optional:-->
<axis:x>5</axis:x>
</axis:testws>
</soapenv:Body>
</soapenv:Envelope>
and it gives me as a response:
faultstring>Missing wsse:Security header in request</fau
SO I add the security header and my request becomes the same as the one written in the tutorial
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:axis="http://axis2wstest">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-
200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-
open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="123">
<wsse:Username>test</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-
200401-wss-username-token-profile-1.0#PasswordText">pass</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<axis:testws>
<!--Optional:-->
<axis:x>5</axis:x>
</axis:testws>
</soapenv:Body>
</soapenv:Envelope>
but the response is the same
soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<faultcode>wsse:InvalidSecurity</faultcode>
<faultstring>Missing wsse:Security header in request</faultstring>
<detail/>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Don't add the security header directly to your request!
Click on Aut at the bottom left. Then you can enter your username/password there.
For more information see: http://www.soapui.org/SOAP-and-WSDL/authenticating-soap-requests.html
As Authorisation type choose Preemptive. (Only in soapUI 4.5.1 as far as I know)