the code I've used at the listing below (server and client) are similiar to the http://ws.apache.org/axis2/1_2/mtom-guide.html, and I didn't work...  at the client, it goes an axis esception "ContentID is null", as showed below.... but, looking at the messages showed by the tcpmonitor, the file seems to be there! The datahandler field cames null....

At 21:26 7/5/2007, you wrote:
Oi LuCa, tudo bem? You are using the 1.0 docs - try the 1.2 docs with the 1.2 release and you should have no problems, as I was testing some stuff with that tutorial and it worked fine.

http://ws.apache.org/axis2/1_2/mtom-guide.html

HTH,
Robert

On 5/7/07, LuCa <[EMAIL PROTECTED] > wrote:
Hello there!

I'm an master's degree student at UFMG university (Brazil).
My work is about  web service, and I'm trying to use AXIS2 to make a web service that sends and receives files.... image files too!

I'm coming for your help, cause the only Axis2 file attachments help source  I've found is at: http://ws.apache.org/axis2/1_0/mtom-guide.html, and I've already spent a lot of time searching some help....

The problem is, I think, the code showed at this site is not updated, particulaly  the image part at this code piece:




===================================================================================

       
   OMElement imageElement =
fac.createOMElement("image", omNs);
        // Creating the Data Handler
for the image.
        // User has the option to use
a FileDataSource or a ImageDataSource
        // in this scenario...
        Image image;
        image = new ImageIO()
              
.loadImage(new FileInputStream(inputImageFileName));
        ImageDataSource dataSource =
new ImageDataSource("test.jpg",image);
        DataHandler dataHandler = new
DataHandler(dataSource);
        //create an OMText node with
the above DataHandler and set optimized to true
        OMText textData =
fac.createOMText(dataHandler, true);
      
imageElement.addChild(textData);
===================================================================================
The " image=new ImageIO()  " does not work, since it seems to exist at an old Axis2 version (0.95) only...

I couldn't find any similiar method at the axis2 actual version.... I have: the 1.1.1 version...

I've tried to use this code like that (not an image datasource, just a filedatasource), at the service skeleton:



===================================================================================



public   first.axiomwsimage.xsd.ReceiveImageResponse receiveImage()        
           {
        try {
    OMFactory fac = OMAbstractFactory.getOMFactory();
         //     creating a namespace
    OMNamespace omNs = fac.createOMNamespace( " http://www.dees.ufmg.br" , "ns");

    OMElement imageElement = fac.createOMElement( "image" , omNs);

            // Creating the Data Handler for the image.
            DataSource dataSource = new FileDataSource( new File( "fig.JPG"));;
            DataHandler dataHandler = new DataHandler(dataSource);

            //create an OMText node with the above DataHandler and set optimized to true
            OMText textData = fac.createOMText(dataHandler, true );
            imageElement.addChild(textData);
            first.axiomwsimage.xsd.ReceiveImageResponse resp = new first.axiomwsimage.xsd.ReceiveImageResponse();
            resp.set_return(imageElement);
       return resp;
    }
    catch (Exception e) {
    return null ;
    }
        }



===================================================================================




My client:


===================================================================================



        public static void main(String [] args) throws Exception {

// create the stub
GetImageServiceStub stub = new GetImageServiceStub();
 
// Enable MTOM in the client side
stub._getServiceClient().getOptions().setProperty(
Constants.Configuration. ENABLE_MTOM , Constants. VALUE_TRUE);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(10000);

// result string
String resultMsg= "";
try {
// invoking the service and getting the response ....
// getting the OMelement from the response  of the webService
OMElement element = stub.receiveImage().get_return();
    OMText binaryNode = (OMText) element.getFirstOMChild();

    String fileName = "test.jpg";

    //Extracting the data and saving
    DataHandler actualDH=(DataHandler) binaryNode.getDataHandler();
  
   
    //DataSource ds = new inp
    FileOutputStream imageOutStream = new FileOutputStream(fileName);
    actualDH.writeTo(imageOutStream);
    resultMsg = "File received!!! Name: "+fileName;
}
catch (Exception e) {
resultMsg = "error\n" +e.getMessage();
}

System. out .println( "Done!\n" +resultMsg);
}




===================================================================================




but it doesn�t work....
I've received the following message at the console window:


===================================================================================




Done!
error
ContentID is null



===================================================================================




When debuggint the client java application, at the binaryNode, the field "dataHandlerObject" came null, so the binaryNode.getDataHandler returns "null"!!!!
Probably is because the datahanldler must be created as an image... I don't know...
Ah, I've enabled the MTOM at Axis2.xml and at the client too....

Could you help me?? I'd thanked you a lot!

below, there is the messages captured with the tcpmon....




===================== REQUEST

=======================================================
POST /axis2/services/GetImageService HTTP/1.1
SOAPAction: "urn:receiveImage"
User-Agent: Axis2
Host: localhost:3333
Transfer-Encoding: chunkedContent-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_8896DF3A02AC07AE161178571190547; type="application/xop+xml"; start="< 0.urn:uuid:[EMAIL PROTECTED]>"; start-info="text/xml"; charset=UTF-8

1e4
--MIMEBoundaryurn_uuid_8896DF3A02AC07AE161178571190547
content-type: application/xop+xml; charset=UTF-8; type="text/xml";
content-transfer-encoding: binary
content-id: < 0.urn:uuid:[EMAIL PROTECTED]>

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header /><soapenv:Body><receiveImage /></soapenv:Body></soapenv:Envelope>
--MIMEBoundaryurn_uuid_8896DF3A02AC07AE161178571190547--
0



===================================================================================


===================== RESPONSE
=======================================================
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=UTF-8
Transfer-Encoding: chunked
Date: Mon, 07 May 2007 20:53:10 GMT

2000
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header /><soapenv:Body><ns1:receiveImageResponse xmlns:ns1=" http://axiomWSimage.first/xsd"><ns1:return><ns:image xmlns:ns=" http://www.dees.ufmg.br ">/9j/4AAQSkZJRgABAQEASABIAAD//gAMQXBwbGVNYXJrDf/bAIQAIRcZHRkVIR0bHSUjIScxUTUxLS0xY0dLO1F1Z3t5c2dxb4KSup6CirCMb3Gi3KSwwMbQ0tB9nOT04sryuszQyAEjJSUxKzFfNTVfyIZxhsjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjI/8QBogAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQ
..... sniped.......
GrZ6wt1deT5RQEHYxbO7HtjilvtXitJkjEZkyAxOcYBrH0f8A4/4Px/nSaz/x+L/1yX+VAXOkuLpYLRrjBZQoIA75qnba3BPJsdWiJ+7nnP5Uuof8gI/9c0/pXPWn/H3D9aAbN5NbRr3yBCRGXKeZu/XGKLvUdOjuGSWJZHXhiY88/lWLD/yEF/67H+ZqPU/+Qlcf9dDQNO5//9k=</ns:image>4a
</ns1:return></ns1:receiveImageResponse></soapenv:Body></soapenv:Envelope>
0




===================================================================================





By the way, the file "fig.jpg" has 11KB only...
Luciana Camara
      
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to