I want to set the value of token in this soap ws header
<soapenv:Enveloppe ...
<soapenv:Header>
<web:token>123456 </web:token>
FROM step named test get idSession in response
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:authentification xmlns:ns1="http://ws.demowebservices.com/">
<bloc1>
<bloc2>
<idSession>e1c64cd9-b933-4f56-ae1f-0f7d7f23942b</idSession>
</bloc2>
I tried to put in-between web:token tag
${test#Response#//ns1:authentification/bloc1/bloc2/idSession}
but it does not work
What should I put instead ?
I'm not sure if this is what you're trying to achieve, however If you have a SOAP Test step called Test Request and you want to use the value of the <soapenv:Header><web:token></soapenv:Header> of this request in another SOAP Test step you can refer this value in the second SOAP Test step request using the follow syntax:
<soapenv:Enveloppe ...
<soapenv:Header>
<web:token>${Test Request#Request#//soapenv:Header/web:token}</web:token>
The syntax ${Test Request#Request#//soapenv:Header/web:token} has three parts, the name of the test step, followed by the property (could be #Request or #Response), and finally the xpath to get the value //soapenv:Header/web:token.
UPDATED:
As you said you've two SOAP Test Request, the first one is called test an has the follow response:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:authentification xmlns:ns1="http://ws.demowebservices.com/">
<bloc1>
<bloc2>
<idSession>e1c64cd9-b933-4f56-ae1f-0f7d7f23942b</idSession>
</bloc2>
</bloc1>
</ns1:authentification>
</soap:Body>
</soap:Envelope>
The second is named for example test 2 (don't care because the second name not affect your purpose) and has the follow request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<web:token>${test#Response#//ns1:authentification/bloc1/bloc2/idSession}</web:token>
</soapenv:Header>
<soapenv:Body>
...
</soapenv:Body>
</soapenv:Envelope>
With ${test#Response#//ns1:authentification/bloc1/bloc2/idSession} you're referencing the idSession value of the test response correctly. Take a look on the http log tab when you send your test 2 as shown in the follow image:
Hope this helps,
Related
I'm trying to send a SOAP Request to a webservice in Delphi XE5. Actually there is a WSDL available which I imported via WSDL Importer. I established a connection to this webservice with the components THTTPRIO (rio) and IdEncoderMIME1 for the HTTP Authentication Request.
The SOAP Request was build via TXMLDocument and has the following structure:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cod=NS_Codelist>
<soapenv:Header/>
<soapenv:Body>
<cod:GetLatestChangeDatesRequest>
<!--Zero or more repetitions:-->
<CodeListID>1035</CodeListID>
</cod:GetLatestChangeDatesRequest>
</soapenv:Body>
</soapenv:Envelope>
Furthermore I received the Porttype of the webservice.
codeserv:= GetCodeListPortType(true,'',rio);
These are methods from the WSDL:
codeserv.GetLatestChangeDates(const body:GetLatestChangeDatesRequestType):GetLatestChangeDatesResponseType
GetLatestChangeDatesRequestType = array of Int64;
GetLatestChangeDatesRequest = GetLatestChangeDatesRequestType;
GetLatestChangeDatesResponseType = array of CodeListLatestChangeDateType;
GetLatestChangeDatesResponse = GetLatestChangeDatesResponseType;
CodeListLatestChangeDateType
property CodeListID: Int64
property LatestChangeDate: TXSDate
I have already tried to set an array of Int64 for the parameter but then it says "element CodeListID is missing".
Unfortunately I don't find a way to send this XML SOAP Request to the webservice and to receive the response. Any ideas?
EDIT: I have tried to use the WSDL methods
var
codeserv: CodeListPortType;
arrIDs: GetLatestChangeDatesRequest;
response: GetLatestChangeDatesResponse;
begin
codeserv:= GetCodeListPortType(true,'',rio);
SetLength(arrIDs,1);
arrIDs[0]:= 1035;
response:= codeserv.GetLatestChangeDates(arrIDs);
But then I receive the following error message: 'invalid content was found starting with element 'long'. One of '{CodeListID}' is expected.'
In the SOAP Request there have to be the element CodeListID. Unfortunately it seems the method GetLatestChangeDates isn't creating the elements in the SOAP Request. The SOAP Request posted above should have been created with this method (hopefully).
Can some explain the best way on SOAP UI Free to achieve the below scenario
Load the response value from one Test Case Web service as a request value on second Test Case Web service.
in Test case 1 Script Assertion
import com.eviware.soapui.support.XmlHolder
def respXmlHolder = new XmlHolder(messageExchange.getResponseContentAsXml())
respXmlHolder.declareNamespace("ns1","http://www.moj.com/api/services/checkout")
def finsess = respXmlHolder.getNodeValue("//ns1:sessresp/ns1:sessionId")
log.info finsess
Log Info shows below 70c8a6f80b6ff0c72502
Now how to automatically load this above sessionid onto Test Case 2 Web Service as shown below.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://www.moj.com/api/services/final">
<soapenv:Header/>
<soapenv:Body>
<typ:FinSessionRequest>
<typ:correlationId>1234</typ:correlationId>
<typ:sessionId>70c8a6f80b6ff0c72502</typ:sessionId>
<typ:username>abcd</typ:username>
<typ:password>1234</typ:password>
</typ:FinSessionRequest>
</soapenv:Body>
</soapenv:Envelope>
You can use Property transfer test step for this task, without Groovy scripting. See more at SoapUI docs. You just pick the source XML element with XPath and similarly the target element. SoapUI will do the replacement when you execute the test step (or the test case). I recommend to use this way as it is transparent.
If you really need to transfer the value with Groovy scripting, you can set a test suite property value in your assertion script:
def testSuite = context.getTestCase().getTestSuite()
testSuite.setPropertyValue("MyId", finsess)
And then place the MyId into your request message:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://www.moj.com/api/services/final">
<soapenv:Header/>
<soapenv:Body>
<typ:FinSessionRequest>
<typ:correlationId>1234</typ:correlationId>
<typ:sessionId>${#TestSuite#MyId}</typ:sessionId>
<typ:username>abcd</typ:username>
<typ:password>1234</typ:password>
</typ:FinSessionRequest>
</soapenv:Body>
</soapenv:Envelope>
This works as long as the two test cases belong to the same test suite.
Karel
I am testing a webservice method which accepts session-id as a parameter.
While testing the same method via SoapUI with a dummy sessionID-Parameter, the server is rejecting the request as it is expecting proper session-id.
How can I solve this? Is there any way where SoapUI can bind the session-id before sending the request?
Please advice me. Thanks
Below is the sample-request which is triggered from SOAP-UI:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.local.com">
<soapenv:Header/>
<soapenv:Body>
<ser:getMultiple>
<!--Optional:-->
<ser:sessionId>1000AJHEFG0987</ser:sessionId>
<!--Optional:-->
<ser:lessonId>95101</ser:lessonId>
<!--Optional:-->
<ser:quantity>1</ser:quantity>
<!--Optional:-->
<ser:impressionRow>1</ser:impressionRow>
</ser:getParametersMultiple>
</soapenv:Body>
</soapenv:Envelope>
Let's say, if you get sessionid in first request's response, and the next request should go here http://{{original endpoint}}/{{SESSION_ID}}), this definitely works:
go to request (not the test request inside test case) where session id should be put into
add a parameter on 'request' tab
name=sessionid, style=template, level=resource. now it is empty in all related test requests
go to test request, 'request' tab
put the path to sessionid value from previous request into 'value' field of sessionid parameter. for example, it is like ${users#Response#$.session_id} where 'users' is the name of endpoint resource, 'session_id' is the name of parameter inside response
Found the solution,
Design your login method which will accept certain inputs and will
return the sessionID as a string
Hit that login method from SOAP-UI and you will get the sessionID in
your response
Use "Property Transfer" option in soap-ui and transfer the received
sessionID to all other requests
Helpful Link : soapui.org/Functional-Testing/transferring-property-values.html
Simple !! :)
I am calling the lists.asmx webservice from CXF.
The following soap call does not return files from list sub folders. It returns folder1,folder2 and file1.pdf
Shared Documents
folder1
file2.docx
file3.pdf
folder2
sub-folder1
file5.pdf
file4.pdf
file1.pdf
SOAP call
POST /_vti_bin/lists.asmx HTTP/1.1 Accept-Encoding: gzip,deflate
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:soap1="http://schemas.microsoft.com/sharepoint/soap/">
<soap:Header/>
<soap:Body>
<soap1:GetListItems>
<soap1:listName>Shared Documents</soap1:listName>
<queryOptions>
<QueryOptions>
<IncludeMandatoryColumns>TRUE</IncludeMandatoryColumns>
<ViewAttributes Scope="RecursiveAll"/>
<DateInUtc>TRUE</DateInUtc>
</QueryOptions>
</queryOptions>
</soap1:GetListItems>
</soap:Body>
</soap:Envelope>
Any clues on how to get files from folder1, folder3 and sub-folder1 included in the result?.
If Lists web service cannot do it, is there an alternative service/method?
Additional Information:
There is another webservice, SiteData (_vti_bin/sitedata.asmx). It has a similar method ( getListItems) and returns all files with just the list name and no additional parameters.The issue is I could not figure out how/where to specify the Paging parameter, as there is NO queryOptions input element like in the Lists webservice.
<soap1:strListName>?</soap1:strListName>
<soap1:strQuery>?</soap1:strQuery>
<soap1:strViewFields>?</soap1:strViewFields>
<soap1:uRowLimit>?</soap1:uRowLimit>
It is possible to get the list contents recursively, using <ViewAttributes Scope="RecursiveAll"/> elment.
There is a silly mistake in my soap envelope. The queryOptions element has no namespace. I fixed in the following text.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:soap1="http://schemas.microsoft.com/sharepoint/soap/">
<soap:Header/>
<soap:Body>
<soap1:GetListItems>
<soap1:listName>Shared Documents</soap1:listName>
<**soap1:**queryOptions>
<QueryOptions>
<IncludeMandatoryColumns>TRUE</IncludeMandatoryColumns>
<ViewAttributes Scope="RecursiveAll"/>
<DateInUtc>TRUE</DateInUtc>
</QueryOptions>
</**soap1:**queryOptions>
</soap1:GetListItems>
</soap:Body>
</soap:Envelope>
Btw, there is a great tool, U2U CAML Builder to build SharePoint CAML. I wish I found that a few weeks ago.
You have to recursively call the service to get all the items within the subfolders. I don't there is an option to do it OOTB. Instead, you can always write your custom SharePoint web service to accomplish this.
http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/16a2d993-2f5e-4242-8e5a-451a78c064a3
http://blogs.msdn.com/b/karthick/archive/2006/03/27/562245.aspx
For some reason SourceGear provide an undocumented Web service on their installations. They actually ask developers to use the API instead because the Web service is kinda messy, but this is a problem in my case because I cannot use this API on a Perl environment, so their solution for my specific case is to use the Web service.
This shouldn't be a problem. Using SOAP::Lite I have connected to several Web services in the past in the same way. But the lack of documentation is a major chaos if you don't know where the SOAP calls can be made. I only have an XML to decipher where to and how to make these calls. It would be great if a real SOAP genius could help me out in this.
This is an example of the login call and the expected response:
Request
POST /fortress/dragnetwebservice.asmx HTTP/1.1
Host: velecloudserver
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.sourcegear.com/schemas/dragnet/LoginPlainText"
<?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>
<LoginPlainText xmlns="http://www.sourcegear.com/schemas/dragnet">
<strLogin>string</strLogin>
<strPassword>string</strPassword>
</LoginPlainText>
</soap:Body>
</soap:Envelope>
Response
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?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>
<LoginPlainTextResponse xmlns="http://www.sourcegear.com/schemas/dragnet">
<LoginPlainTextResult>int</LoginPlainTextResult>
<strAuthTicket>string</strAuthTicket>
</LoginPlainTextResponse>
</soap:Body>
</soap:Envelope>
I'm looking for a way to be able to assemble this somehow. This is my Perl example:
my $soap = SOAP::Lite -> uri ('http://velecloudserver/fortress/dragnetwebservice.asmx') -> proxy('http://velecloudserver/fortress/dragnetwebservice.asmx/LoginPlainText');
my $som = $soap->call('LoginPlainText', SOAP::Data->name('LoginPlainText')->value(
\SOAP::Data->value([
SOAP::Data->name('strLogin')->value( 'admin' ),
SOAP::Data->name('strPassword')->value('Adm1234'),
]))
);
Any tip would be appreciated.
Start by pointing wget/curl/lwp/etc. at http://velecloudserver/fortress/dragnetwebservice.asmx?WSDL
and see if you get a WSDL file back.
If you do, then compare it to the four types listed in the SOAP::Lite POD.
Your Request example looks like the Docment/Literal form, so you might end up writing something like this:
use SOAP::Lite;
my $soap = SOAP::Lite->new( file => 'http://velecloudserver/fortress/dragnetwebservice.asmx?WSDL');
$soap->on_action( sub { "urn:dragnetservice#LoginPlainText" });
$soap->autotype(0);
$soap->default_ns('urn:LoginPlainText');
my $som = $soap->call("LoginPlainText",
SOAP::Data->name('strLogin')->value( 'admin' ),
SOAP::Data->name('strPassword')->value('Adm1234'),
);
die $som->fault->{ faultstring } if ($som->fault);
print $som->result, "\n";
If you don't get WSDL back, I'd try replacing the constructor call with:
my $soap = SOAP::Lite->new( proxy => 'http://velecloudserver/fortress/dragnetwebservice.asmx');
The last time I worked with SOAP::Lite, I wrote a short program similar to the one above, and I ran it under the debugger. Before I executed the $soap->call() line, I peeked at the guts of the $soap object and looked at the request payload to see if the XML matched some working XML that I had by using the soapUI.org java client.
I had to read the POD a couple of times, and I dug into the source to figure our how some of the methods like default_ns() affected the generated XML. Once I did that, it all made a lot more sense.
Note: SOAP::Lite likes to die() when it fails. Wrap your calls in an eval{} for production use.