Problem with web-Service for Taverna

2 posts / 0 new
Last post
cybertop
cybertop's picture
Problem with web-Service for Taverna

Hi to all
I have a problrm with a web-service for taverna.

I java implemented in a web-service which takes in input two parameters (String) and returns a string.
With a client written in java always work, when the amount WSDL (AXIS2) Tavern sees only one parameter input.
Who knows?

Carryover the code of web service

public class Servizio {

private String pathInFile;

public String uploadFile(String name, String attchmentID) {

MessageContext inMessageContext = MessageContext.getCurrentMessageContext();

OperationContext operationContext = inMessageContext.getOperationContext();

MessageContext outMessageContext = null;
try {

outMessageContext = operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Attachments attachment = inMessageContext.getAttachmentMap();

pathInFile = getAttchment(attachment, attchmentID);

/*** Ho ricevuto tutti i dati necessari. Sono pronti per essere processati
*
* Dati necessari sono: inputFilePath indica il path del file ricevuto (formato zip)
* inputBean contiene i valori per l'elaborazion dei dati(+algoritmo scelto)
*
* ***/

//ProcessingInput processInput = new ProcessingInput(inputFilePath,inputBean);

/**
* Il metodo mi dovra tornare una stringa contente il path del file
* in cui sono stati scriti i riultati
*/

//String resultFilePath = processInput.esegui();

File f = new File(pathInFile);

String idFile = setAttchment(f, outMessageContext);

return f.getAbsolutePath()+"--Param :"+name+"---Idfile: "+idFile;

}

/**
*
* @param attachment
* @param attchmentID
* @return
*/
private String getAttchment(Attachments attachment, String attchmentID){

DataHandler dataHandler = null ;

File dir = null;

String extFile =".zip";

boolean trovato = true;

File outFilePath = null;

try{
int nome= 0;

dir = new File ("/media/DATI/Progetti/java/Linux/UniT/Servizio_MS-A/Server/Input");

/*** Controllo se esiste la cratella Temp ***/
if(!dir.exists())
dir.mkdir();

dataHandler = attachment.getDataHandler(attchmentID);

outFilePath = new File(dir+File.separator+"temp_00"+nome+"_DataSource"+extFile);

/**
* Verifico se esiste un file con lo stesso nome
*/

do{
if (!outFilePath.exists())
trovato = false;

else{
nome++;
outFilePath = new File(dir+File.separator+"temp_00"+nome+"_DataSource"+extFile);
}

}while(trovato);

if (dataHandler!=null){

FileOutputStream outputStream = new FileOutputStream(outFilePath);

dataHandler.writeTo(outputStream);

outputStream.flush();

}

} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return outFilePath.getAbsolutePath();

}

/**
*
* @param f
* @param outMessageContext
* @return
*/
private String setAttchment(File f, MessageContext outMessageContext){

String idFile = null;

if(f!=null){

DataSource DataSource = new FileDataSource(f);

DataHandler DataHandler = new DataHandler(DataSource);

idFile = outMessageContext.addAttachment(DataHandler);
}

return idFile;

}

}

Thanks

bgood
bgood's picture
How are you testing it with

How are you testing it with your java client? Are you building directly from the same WSDL that taverna is using?

The problem of recognizing the inputs wouldn't be in the code, it would be in the WSDL document.

Hope that helps