SOAP request with certain tags without namespace - soap

Would be the following SOAP request valid according to the standard?
<?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>
<ns2:ServiceReq xmlns:ns2="http://www.tibco.com/service" xmlns:ns1="http://www.tibco.com/framework">
<ns1:HeaderIn>
<ns1:countryISO>FR</ns1:countryISO>
<ns1:callerDateTime>2021-11-26T15:50:08.742Z</ns1:callerDateTime>
</ns1:HeaderIn>
<ns2:request>
<entete>
<profile>Default</profile>
</entete>
<input>
<type>W</type>
<codeRegion>X</codeRegion>
</input>
</ns2:request>
</ns2:ServiceReq>
</soapenv:Body>
</soapenv:Envelope>
I am not sure because certain tags don't have a namespace

There are multiple levels of valid here:
Is it a valid SOAP message as per the SOAP standard? Yes. The SOAP envelope and body tags seem valid.
Is it a valid XML format? Yes, it's a well formed XML file.
Are those elements without a namespace prefix valid? Yes. Elements can be in a default namespace or in no namespace at all.
Is the actual content of the body a valid messages? You can only tell if you verify the message you posted against the expected message as defined in the WSDL file of the web service.
All the elements in the body of the SOAP message should belong to specific namespaces, but sometimes a developer forgets to add a namespace annotation on the element, or copy-pastes something from some place else, or whatever, and you end up with weird looking XMLs like that. The service works and the message is correctly parsed, but it just looks funny.

Related

Why there are different request definition for one wsdl

I have been provided a WSDL by client at the beginning of the project, I ended up creating a request and response objects for given WSDL using SOAP UI, where the request object would look as follows,
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:def="http://DefaultNamespace">
<soapenv:Header/>
<soapenv:Body>
<def:someOperation soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<in0 xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">SOME_DATA</in0>
</def:someOperation>
</soapenv:Body>
</soapenv:Envelope>
But when the actual request coming from the production environment for the same wsdl is,
<?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>
<someOperation xmlns="urn:SOMEService">
<in0>SOME_DATA</in0>
</someOperation>
</soap:Body>
</soap:Envelope>
If you observed the name spaces are the same but it does has difference for names like in 1st request its <soapenv:Envelope and same in the 2nd request is <soap:Envelope in each node of xml, the definition of operation is also different in both the request in 1st it is,
<def:someOperation soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<in0 xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">SOME_DATA</in0>
</def:someOperation>
and in 2nd it is,
<someOperation xmlns="urn:SOMEService">
<in0>SOME_DATA</in0>
</someOperation>
I do not know why the interpretation is different, and is it safe to have to change from 1st to 2nd.
IN both the cases actual operation is working fine I do not have any issues with that, it is just cant able to figure out reason of difference.
Could somebody please assist me with this or any direction to a document which could clarify my doubt would be great.
it does has difference for names like in 1st request its <soapenv:Envelope and same in the 2nd request is <soap:Envelope in each node of xml
Here soapenv and soap are local prefix names of namespace=http://schemas.xmlsoap.org/soap/envelope/. Hence, logically both are same and has no difference.
the definition of operation is also different in both the request in 1st v/s 2nd
In case of 1st, def:someOperation XML nodes belongs to namespace = xmlns:def="http://DefaultNamespace"
And in 2nd case, name space "urn:SOMEService" is directly defined with XML Nodes So
if DefaultNamespace is exactly same as SOMEService, the it means both of the XML Operation XMLs are same.
Hence,
soapenv v/s soap are same in your case.
Operations, you could conclude based on actual value of SOMEService v/s DefaultNamespace.
Hope it helps.

How to compose SPML v2 'modify' request to delete object attribute

I need to maintain an Active Directory service via SPMLv2 SOAP requests to an Active Roles Server.
I'm trying to do something ostensibly simple: delete the telephoneNumber attribute from an object. I'd never heard of SPML before so I spent some time trying to understand the specification available on the list of OASIS open standards.
I've figured out how to do it if the value is known. For example, the payload below will delete the telephoneNumber attribute if it matches the value '12345', but not any other value.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:oasis:names:tc:SPML:2:0">
<soapenv:Header/>
<soapenv:Body>
<urn:modifyRequest xmlns:spml="urn:oasis:names:tc:SPML:2:0">
<urn:psoID ID="CN=Some User,OU=User,OU=Accounts,DC=someorganisation,DC=org"/>
<urn:modification>
<modification name="telephoneNumber" operation="delete" xmlns="urn:oasis:names:tc:DSML:2:0:core">
<value>12345</value>
</modification>
</urn:modification>
</urn:modifyRequest>
</soapenv:Body>
</soapenv:Envelope>
What I can't figure out is how to do this for an unspecified value, i.e. I don't care what the value is before I delete it, I just want to delete it. I suspect this has something to do with the SelectionType and I just need to use a 'match anything' selector, but I'm having trouble understanding the specification.
Any ideas?
Edit: To add to the confusion, I see we're using the DSMLv2 namespace for the modification. I just pulled this from a sample on the Active Roles SPML service documentation so I don't know how/why it works. The SPML specification does mention DSML but doesn't give any context around its usage as far as I can tell. It could actually be a vendor specific implementation.
Figured out a solution/work-around to this problem.
To delete the attribute without knowing its current value, you can simply include a 'replace' operation to first set some arbitrary value and include it in the same modify request as the 'delete' operation.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:oasis:names:tc:SPML:2:0">
<soapenv:Header/>
<soapenv:Body>
<urn:modifyRequest xmlns:spml="urn:oasis:names:tc:SPML:2:0">
<urn:psoID ID="CN=Some User,OU=User,OU=Accounts,DC=someorganisation,DC=org"/>
<urn:modification>
<modification name="telephoneNumber" operation="replace" xmlns="urn:oasis:names:tc:DSML:2:0:core">
<value>deleteMe</value>
</modification>
<modification name="telephoneNumber" operation="delete" xmlns="urn:oasis:names:tc:DSML:2:0:core">
<value>deleteMe</value>
</modification>
</urn:modification>
</urn:modifyRequest>
</soapenv:Body>
</soapenv:Envelope>

How to get response value from Currency Converter service response through groovy script in SoapUI?

I'm using Currency Converter webservice to practice groovy script in SoapUI Pro.
In that, I have created a property that should get response / output of the Currency Converter service through groovy script.
For that, I tried the following script which gets all the raw response data :(
I need to get the exact result i.e. converted value and assign to the property.
Can anyone provide me the correct groovy script?
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
<soapenv:Header/>
<soapenv:Body>
<web:ConversionRate>
<web:FromCurrency>USD</web:FromCurrency>
<web:ToCurrency>INR</web:ToCurrency>
</web:ConversionRate>
</soapenv:Body>
</soapenv:Envelope>
Response:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ConversionRateResponse xmlns="http://www.webserviceX.NET/">
<ConversionRateResult>60.54</ConversionRateResult>
</ConversionRateResponse>
</soap:Body>
</soap:Envelope>
Thanks
Karunagara Pandi
First you need access to the Response.
def conversionRateResult = context.expand( '${step_name#Response#//*:ConversionRateResult}' )
Then to assign it to a property depends on multiple things: 1) where are you doing it from, and 2) where do you want the property assigned.
To crawl the hierarchy from a script step, you would do something like:
testRunner.testCase.setPropertyValue("property_name", conversionRateResult)
Consider browsing through the documentation and API.

SoapUI Pro, validating response using groovy script

I am using SoapUI Pro to test web services used for creating postal despatch shipments.
I am using a groovy script to validate my web service requests. If I am expecting the request to succeed I look for a value of ‘Allocated’ in the ‘status’ field. If I am expecting the request to fail I look for the correct error code and errorDescription in the integration footer.
Sometimes a valid request will have a warning message (e.g. to inform user that field data is too long and has been truncated). I also want to validate these warning messages as well.
I specify the element path that I want to validate in my data source file and then pass it to my groovy script that does the validation.
The groovy script retrieves the value in the element path and assigns it to a variable actualReturn1 using ..
actualReturn1 = holder.getNodeValue(testElementOne);
where testElementOne could be either
//NS1:completedShipmentInfo/NS1:status/status/statusCode/code
OR
//NS1:createShipmentResponse/NS1:integrationFooter/errors/error/errorCode
The first path is valid and correctly assigns the value of this status field to actualReturn1.
But the second path does not appear to be valid and assigns null to actualReturn1.
Below are part of my 2 response files the elements I’m trying to extract data from.
Response with status element that is extracted successfully..
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<NS1:createShipmentResponse xmlns:NS1="http://www.royalmailgroup.com/api/ship/V1">
<NS1:integrationHeader>
<dateTime xmlns="http://www.royalmailgroup.com/integration/core/V1">2013-12-02T17:06:11</dateTime>
<version xmlns="http://www.royalmailgroup.com/integration/core/V1">1</version>
<identification xmlns="http://www.royalmailgroup.com/integration/core/V1">
<applicationId>111111113</applicationId>
<transactionId>420642961</transactionId>
</identification>
</NS1:integrationHeader>
<NS1:completedShipmentInfo>
<NS1:status>
<status>
<statusCode>
<code>Allocated</code>
</statusCode>
</status>
Response with errorCode that can not be extracted…
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<NS1:createShipmentResponse xmlns:NS1="http://www.royalmailgroup.com/api/ship/V1">
<NS1:integrationHeader>
<dateTime xmlns="http://www.royalmailgroup.com/integration/core/V1">2013-12-02T17:06:13</dateTime>
<version xmlns="http://www.royalmailgroup.com/integration/core/V1">1</version>
<identification xmlns="http://www.royalmailgroup.com/integration/core/V1">
<applicationId>111111113</applicationId>
<transactionId>420642961</transactionId>
</identification>
</NS1:integrationHeader>
<NS1:integrationFooter>
<errors xmlns="http://www.royalmailgroup.com/integration/core/V1">
<error>
<errorCode>E1101</errorCode>
<errorDescription>Name is a required field</errorDescription>
</error>
</errors>
Could someone tell me why this isn't working for the second response? If I have warning messages in a valid response then I'm also not able to extract the value. Is it because this is in the integrationFooter?
Happened to see this now, so adding the answer.
In the 2nd case, it was not working for you because of the namespace issue.
The element, errors is using default namespace and is different from its parent element integrationFooter. And in your xpath, no namespace was referred to element errors and its child elements.
Here is the script that works for 2nd case:
def xml = '''
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<NS1:createShipmentResponse xmlns:NS1="http://www.royalmailgroup.com/api/ship/V1">
<NS1:integrationHeader>
<dateTime xmlns="http://www.royalmailgroup.com/integration/core/V1">2013-12-02T17:06:13</dateTime>
<version xmlns="http://www.royalmailgroup.com/integration/core/V1">1</version>
<identification xmlns="http://www.royalmailgroup.com/integration/core/V1">
<applicationId>111111113</applicationId>
<transactionId>420642961</transactionId>
</identification>
</NS1:integrationHeader>
<NS1:integrationFooter>
<errors xmlns="http://www.royalmailgroup.com/integration/core/V1">
<error>
<errorCode>E1101</errorCode>
<errorDescription>Name is a required field</errorDescription>
</error>
</errors>
</NS1:integrationFooter>
</NS1:createShipmentResponse>
</soapenv:Body>
</soapenv:Envelope>'''
def holder = new com.eviware.soapui.support.XmlHolder( xml )
holder.declareNamespace('a','http://www.royalmailgroup.com/api/ship/V1')
holder.declareNamespace('b','http://www.royalmailgroup.com/integration/core/V1' )
def errorCode = holder.getNodeValue( "//a:integrationFooter/b:errors/b:error/b:errorCode" )
assert errorCode == 'E1101'

Getting 400 Bad Request while trying to upload contents to sharepoint site using Copy.asmx web service

I am trying to upload content to SharePoint site using its Copy.asmx web service's CopyIntoItems operation from one of my iPhone applications.
Here is the sample xml That I am trying to POST.
<?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>
<CopyIntoItems xmlns="http:"//schemas.microsoft.com/sharepoint/soap/"><SourceUrl>http://null</SourceUrl><DestinationUrls><string>mytestsite/Upload Library/Check_File_Upload.txt</string></DestinationUrls><Fields><FieldInformation Type="File" DisplayName="Name" InternalName="FileLeafRef" Value="Check_File_Upload.txt" /><FieldInformation Type="Guid" DisplayName="GUID" InternalName="GUID" Value="{21026DFC-E19E-470E-8B1D-7D7C5FA84FF3}" /></Fields><Stream>VGhpcyBpcyBhIHRlc3QgZmlsZSB0byBjaGVjayB1cGxvYWQgZnVuY3Rpb25hbGl0eS4gYW5kIGNoZWNraW5nIGFnYWluLg==</Stream></CopyIntoItems>
</soap:Body>
</soap:Envelope>
Can anyone help me to figure out the issue?
I'm was able to do it with Java. See this thread
Gettting 400 Bad Request while uploading file to SharePoint 2010 using Copy.CopyIntoItems web service
Hope this helps.
Also here are some very useful field type that I've compiled. I'm using SharePoint 2010
Choice List
fieldInfo.setDisplayName("Day Of Week");
fieldInfo.setType(FieldType.CHOICE);
fieldInfo.setValue("Friday");
Multi Choice List, note that each value is separated by ;#
fieldInfo.setDisplayName("Hobbies");
fieldInfo.setType(FieldType.MULTI_CHOICE);
fieldInfo.setValue("Biking;#Reading");
Enterprise Keywords,
fieldInfo.setDisplayName("Enterprise Keywords");
fieldInfo.setType(FieldType.NOTE);
fieldInfo.setValue("-1;#wind;#-1;#turbine");
Managed Metadata. Important, note that the displayname must be append to “_0” and the value must be in the format of -1#SomeValue|guid as shown below
fieldInfo.setDisplayName("MyMetadata_0");
fieldInfo.setType(FieldType.NOTE);
fieldInfo.setValue("-1;#wind|4c29faf0-bea6-4032-893f-d5aaea458728;#-1;#turbine|6e552448-77d1-4349-bc11-52debdcbc860");
Content Type. You can get the Id of the content type by viewing on the content type properties and note the id in the url, something like. Get the value of the param, ctype https://eimsscnqa.sandia.gov/sites/DocLib026/_layouts/ManageContentType.aspx?ctype=0x0101005C02449B3F60DF42A78192F51AAD4A5202e
fieldInfo.setDisplayName("Content Type Id");
fieldInfo.setType(FieldType.TEXT);
fieldInfo.setValue("0x0101005C02449B3F60DF42A78192F51AAD4A5202e");