cancel
Showing results for 
Search instead for 
Did you mean: 

How to get an information from Remote Server and use it in soapUI.

SOLVED
Contributor

How to get an information from Remote Server and use it in soapUI.

Hi,

   

     Is there any way that I can fetch a file path from remote server and the same file path will be used in my SoapUI rest Project 

 

Thanks 

Pritish Panda

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: How to get an information from Remote Server and use it in soapUI.

Here you go:

 

/**
* edit and write your command below
*/
def command = "you batch script command"
log.info command
def process = command.execute()
def outputStream = new StringBuffer()
def errorStream = new StringBuffer()
process.consumeProcessOutput(outputStream, errorStream)
process.waitFor()
log.info("return code: ${process.exitValue()}")
log.error("standard error: ${process.err.text}")
log.info("standard out: ${process.in.text}" + outStream.toString())
context.testCase.setPropertyValue("propertyName", outStream.toString())

The output of batch script is now set into test case level proprty called "propertyName". And use property expansion i.e., ${#TestCase#propertyName} where it is needed.



Regards,
Rao.
14 REPLIES 14
Community Manager

Re: How to get an information from Remote Server and use it in soapUI.

Hi Pritish,

 

Could you please clarify your request? What remote file do you want to get? What do you mean by a remote server?

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
Contributor

Re: How to get an information from Remote Server and use it in soapUI.

Hi Tanya,

 

  Actually I have a file in my Linux server / HDFS (Remote location) & I would like to featch the file path from linux server .

So I am able to fetch the file path by using a ShellScript.  Same file path I would like to use in my RestStep in SoapUI .

 

Is there any way that I can pass that value to SoapUI So that can be used in my RestStep ?

 

 

 

Thanks 

Pritish Panda

 

 

 

Community Hero

Re: How to get an information from Remote Server and use it in soapUI.

Do you mean download using ftp/scp to local machine?
By the way, if you can get the file path using shell script, you download it using the same. Isn't it?


Regards,
Rao.
Contributor

Re: How to get an information from Remote Server and use it in soapUI.

No Rao,

 

I don't want to download the file, I just want to pass the File path to SoapUI so that I can use that in my Json and Execute the RestStep .

 

I mean the output of shellscript will be used in soapui . 

 

although ,I wrote the output in text file inside Remote Linux server but i am not able to read the file .

 

Please give me any solution for this ?

 

 

Thanks 

Pritish Panda

 

 

Community Hero

Re: How to get an information from Remote Server and use it in soapUI.

Not really clear what you are looking for?
Is the file on remote machine? If so, is that static path or dynamic path? If static, set it in property of test case / suite/project level and use it in rest request as you needed.
How are you running the shell script? You may run the shell script from groovy script and capture the output and set to property as mentioned above in case of dynamic remote file path.



Regards,
Rao.
Contributor

Re: How to get an information from Remote Server and use it in soapUI.

Hi Rao,

 

  Ya that is what I am looking for , How can we capture the output of the ShellScript in Groovy ? 

That Shell Script output will return me the File path and that path will be used in my RestRequest .

 

 

Thanks 

Pritish Panda

Highlighted
Community Hero

Re: How to get an information from Remote Server and use it in soapUI.

Here you go:

 

/**
* edit and write your command below
*/
def command = "you batch script command"
log.info command
def process = command.execute()
def outputStream = new StringBuffer()
def errorStream = new StringBuffer()
process.consumeProcessOutput(outputStream, errorStream)
process.waitFor()
log.info("return code: ${process.exitValue()}")
log.error("standard error: ${process.err.text}")
log.info("standard out: ${process.in.text}" + outStream.toString())
context.testCase.setPropertyValue("propertyName", outStream.toString())

The output of batch script is now set into test case level proprty called "propertyName". And use property expansion i.e., ${#TestCase#propertyName} where it is needed.



Regards,
Rao.
Contributor

Re: How to get an information from Remote Server and use it in soapUI.

Hi Rao , 

 

import java.io.InputStream;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.SftpException;
import com.jcraft.jsch.*
import java.io.*
import java.lang.*


JSch jsch = new JSch();
Session session = jsch.getSession("admin","192.168.2.32", 22);
session.setPassword("admin123");
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect()
Channel channel = session.openChannel("exec");
channel.connect();
//def command=((ChannelExec)channel).setCommand("bash /home/bedrock/Soapui_Automation/test.sh");
def command = "bash /home/bedrock/Soapui_Automation/test.sh"
def process = command.execute()
def outputStream = new StringBuffer()
def errorStream = new StringBuffer()
process.consumeProcessOutput(outputStream ,errorStream)
process.waitFor()
log.info("return code: ${process.exitValue()}")
log.error("standard error: ${process.err.text}")
log.info("standard out: ${process.in.text}" + outputStream.toString())
channel.disconnect();
session.disconnect();

 

 

I am trying with this code but its not working for me .

 

Responce-: 

Thu Jan 28 15:00:18 IST 2016:INFO:return code: 1

Thu Jan 28 15:00:18 IST 2016:ERROR:standard error:

Thu Jan 28 15:00:18 IST 2016:INFO:standard out:

 

 

Can you check it out where is the problem in the above code ?

 

 

Thanks 

Pritish Panda

 

 

 

 

Community Hero

Re: How to get an information from Remote Server and use it in soapUI.

1. the initial question answered, close that if you are satisfied.
2. this is a new question, please open a new topic.


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Top Kudoed Authors