axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thilina Gunarathne" <cset...@gmail.com>
Subject Re: Unable to retrieve attachment using AXIS2
Date Tue, 25 Sep 2007 19:18:46 GMT
Hi,
Will it be possible for you to post your service implementation code..
Are you using any data binding mechanism in the server side.

Your WSDL does not seem to define any binary content.. Are you
planning to use MTOM or plain Soap with Attachments.

Have a look at the following articles..
http://ws.apache.org/axis2/1_2/mtom-guide.html
http://wso2.org/library/1148
http://wso2.org/library/1675

thanks,
Thilina

On 9/25/07, s n <axis_2_user@yahoo.com> wrote:
>
> Hi All,
>
> I am a new AXIS 2 user. I am not too familiar with SOAP either.
> I am trying to write a class which would connect to a web server which
> offers three services namely,
>
> 1. getAnnotation
> 2. getLastUpdate
> 3. getAllArrays
>
> The first service requires two strings as input and returns a file. The
> second and third do not require any input parameters and return a String.
> I have been successful in using  the second and third service. The first one
> (getAnnotation) is giving me a hard time. I have tried following the
> examples in the Axis2 examples directory, but have not been able to retreive
> the file. I have attached the WSDL file in the email.
> Any help would be highly appreciated.
>
> Thanks!
>
>
> The Error :
>
>
> Response Envelope:
>
> <?xml version='1.0' encoding='utf-8'?>
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
> <soap:Body>
> <getAnnotationResponse xmlns="urn:rsrcSOAP">
> <file xsi:type="xsd:string">affy_HG-U133A</file>
> </getAnnotationResponse>
> </soap:Body>
> </soap:Envelope>
>
> MessageID:urn:uuid:6EB4D3C78EEACF75631190730622370
> Messagebody:[MessageContext:
> logID=urn:uuid:6EB4D3C78EEACF75631190730623746]
> File Name : affy_HG-U133A
> File element id:urn:uuid:6EB4D3C78EEACF75631190730623746
> java.lang.Exception: Cannot find the data handler.
>     at
> org.tigr.remote.soap.SoapCall.main(SoapCall.java:120)
>
>
>
>
>
> My code looks as follows:
>
>
> public class SoapCall {
>
>      private static EndpointReference targetEPR = new
> EndpointReference("http://web-dev.dfci.harvard.edu/tgi/cgi-bin/tgi/SOAP/rsrc.cgi");
>
>      public static void main(String[] args) {
>
>          try {
>              SOAPFactory fac = (SOAPFactory)
> OMAbstractFactory.getSOAP11Factory();
>              SOAPEnvelope envelope = (SOAPEnvelope)
> fac.getDefaultEnvelope();
>
>
>
>              OMNamespace omNs = fac.createOMNamespace("urn:rsrcSOAP",
> "rsrcSOAP");
>
>              //The method is getAnnotation and input parameters is the
> hardcoded value "affy_HG-U133A"
>              // and "CLONE_ID". I have used "arrayName" and "fields" to
> denote the two OMElements because
>              //the "part name" fields in the WSDL file for the "message name
> = getAnnotationRequest"
>              //were "arrayName" and "fields" respectively
>
>              OMElement method = fac.createOMElement("getAnnotation", omNs);
>
>              OMElement value1 = fac.createOMElement("arrayName", omNs);
>              value1.setText("affy_HG-U133A");
>
>              OMElement value2 = fac.createOMElement("fields", omNs);
>              value2.setText("CLONE_ID");
>              method.addChild(value1);
>              method.addChild(value2);
>              envelope.getBody().addChild(method);
>
>
>              ServiceClient client = new ServiceClient();
>              OperationClient operationClient =
> client.createClient(ServiceClient.ANON_OUT_IN_OP);
>
>              //creating message context
>              MessageContext outMsgCtx = new MessageContext();
>
>              //assigning message context's option object into instance
> variable
>              Options opts = outMsgCtx.getOptions();
>
>              //setting properties into option
>              opts.setTo(targetEPR);
>              opts.setAction("urn:rsrcSOAP#getAnnotation");
>
>
>
>              outMsgCtx.setEnvelope(envelope);
>              operationClient.addMessageContext(outMsgCtx);
>              operationClient.execute(true);
>              MessageContext response =
> operationClient.getMessageContext("In");
>              SOAPBody body = (SOAPBody) response.getEnvelope().getBody();
>              OMElement element = body.getFirstChildWithName(new
> QName("urn:rsrcSOAP","getAnnotationResponse"));
>
>
>
>
>              System.out.println("File Name : "
>                      + element.getFirstChildWithName(new
> QName("urn:rsrcSOAP","file")).getText());
>
>              OMElement fileElement =
> element..getFirstChildWithName(new
> QName("urn:rsrcSOAP","file"));
>
>              //retrieving the ID of the attachment. The ID string has a "]"
> character at the end.
>              String fileElementID=response.getLogIDString();
>
>
>              String temp1=fileElementID.split("=")[1];
>              String temp2=temp1.replace(']', ' ');
>
>
>              DataHandler dataHandler = response.getAttachment(temp2);
>              if (dataHandler!=null){
>                  // Writing the attachment data (graph image) to a file
>                  File graphFile = new File("response.txt");
>                  FileOutputStream outputStream = new
> FileOutputStream(graphFile);
>                  dataHandler.writeTo(outputStream);
>                  outputStream.flush();
>                  System.out.println("Download statistics graph saved to :" +
> graphFile.getAbsolutePath());
>              }else
>              {
>                  throw new Exception("Cannot find the data handler.");
>              }
>
>
>
>
>         }catch(Exception e) {
>             e.printStackTrace();
>         }
>
>
>         }
>
>
>
>
>
>
>
>  ________________________________
> Need a vacation? Get great deals to amazing places on Yahoo! Travel.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Thilina Gunarathne  - http://thilinag.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message