Re: using MTOM in a AXIOM-based WS

2007-04-20 Thread Michele Amoretti

No, I tried this but the problem persists: only 24KB of the file are
transferred from the service to the client. :(

Michele

On 4/19/07, Masin, Valerie [EMAIL PROTECTED] wrote:


A colleague had this problem (when using Sun's webserver) and fixed it by
setting this on the client.
stub._getServiceClient().getOptions().setProperty(
HTTPConstants.CHUNKED,
Constants.VALUE_FALSE);

I don't know if there is a way to say the same thing from the server, or
if it is even necessary. The reason had something to do with whether the
length was being passed. Sorry I am vague but this didn't happen directly to
me so I don't know the exact particulars.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Michele Amoretti
Sent: Thursday, April 19, 2007 8:50 AM
To: axis-user@ws.apache.org
Subject: Re: using MTOM in a AXIOM-based WS

Ok, it is setProperty()

Now I managed to transfer a file from the service to the client, but if I
try to transfer a file  23963 Bytes, the file is cut.

Should I make some adjustments in axis2.xml, or in Tomcat configuration?

I tried to enable caching both at the server side and at the client side,
as explained in the tutorial:
   options.setProperty(Constants.Configuration.CACHE_ATTACHMENTS,
Constants.VALUE_TRUE);
options.setProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR,
C://axisTemp);
options.setProperty(Constants.Configuration.FILE_SIZE_THRESHOLD, 4);

but with these lines, the client blocks immediately when trying to invoke
any operation of the service (not only the one involving the file
transfer..).

Any idea?

Thanks


On 4/18/07, Masin, Valerie [EMAIL PROTECTED] wrote:
 I believe it is setProperty(), not set() on the options object

 -Original Message-
 From: Michele Amoretti [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, April 18, 2007 1:24 PM
 To: axis-user@ws.apache.org
 Subject: using MTOM in a AXIOM-based WS

 Hello,

 I am trying to create a new version of the quickstartaxiom sample,
with the StockQuoteService providing a getPriceFile operation which returns
a file using MTOM.

 In the MTOM tutorial unfortunately there are only parts of code (I
cannot find a complete example in axis2-1.1.1 - the mtom sample is not
based on AXIOM) thus I had to write the other parts, but since I have some
problems in invoking the service I think I have made a mistake somewhere.


 My new ***AXIOMClient*** should set

 options.set(Constants.Configuration.ENABLE_MTOM,
 Constants.VALUE_TRUE);

 as explained in the tutorial, but the Options class has no set
 method and I cannot find the right one..

 Btw, I added to the client the following method:

public static OMElement getPriceFilePayload(String priceFileName) {
 OMFactory fac = OMAbstractFactory.getOMFactory();
 OMNamespace omNs = fac.createOMNamespace(

 http://quickstart.samples/xsd;, tns);

 OMElement method = fac.createOMElement(getPriceFile, omNs);
 OMElement value = fac.createOMElement(priceFileName, omNs);
 value.addChild(fac.createOMText(value, priceFileName));
 method.addChild(value);
 return method;
 }

 and in the main() method of the client I added the following part, for
getFilePrice invocation:

 OMElement getPriceFilePayload = getPriceFilePayload(
prova.txt); ...
 result = sender.sendReceive(getPriceFilePayload);
 OMElement ele = result.getFirstElement();
 OMText binaryNode = (OMText) ele.getFirstOMChild();
 DataHandler actualDH = (DataHandler)
binaryNode.getDataHandler();
 File file = new File(prova.txt);
 FileOutputStream fileOutputStream = new
FileOutputStream(file);
 actualDH.writeTo(fileOutputStream);
 fileOutputStream.flush();
 fileOutputStream.close();



 In the ***StockQuoteService*** the getPriceFile method is implemented as
follows:


  public OMElement getPriceFile(OMElement element) throws
XMLStreamException {
 element.build();
 element.detach();

 OMElement fileNameElement = element.getFirstElement();
 String fileName = fileNameElement.getText();

 System.out.println(fileName =  + fileName);

 OMFactory fac = OMAbstractFactory.getOMFactory();
 OMNamespace omNs =
 fac.createOMNamespace(http://quickstart.samples/xsd;,
ns);
 OMElement fileElement = fac.createOMElement(file, omNs);

 FileDataSource dataSource =
 new FileDataSource(fileName);

 DataHandler dataHandler = new DataHandler(dataSource);

 // create an OMText node with the above DataHandler and set
optimized to true
 OMText textData = fac.createOMText(dataHandler, true);

 fileElement.addChild(textData);

 OMElement method = fac.createOMElement(getPriceFileResponse,
omNs);
 OMElement value = fac.createOMElement(priceFile

Re: using MTOM in a AXIOM-based WS

2007-04-20 Thread Thilina Gunarathne

stub._getServiceClient().getOptions().setProperty(
 HTTPConstants.CHUNKED,
Constants.VALUE_FALSE);

But doing this forces the message to be buffered in the client side 
this might make large attachments to fail..

 Now I managed to transfer a file from the service to the client, but if I
try to transfer a file  23963 Bytes, the file is cut.

Are you getting any error messages...
Please try increasing the socket time out by using
options.setTimeOutInMilliSeconds()...

Thanks,
Thilina

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

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



Re: using MTOM in a AXIOM-based WS

2007-04-20 Thread Michele Amoretti

Argh I am sorry, I made a mistake and I was transferring another file (of
24KB size) and saving it with the wrong name (and extension).

Now I can say that mymtomwithaxiomexample works properly and could
be inserted in the samples folder of axis2 distribution!

I only have one doubt about the WSDL:

For the
operation which has a parameter which is a binary file, which type
should I declare for the parameter? string?

In my enhanced StockQuoteservice.wsdl (which has a getPriceFile method
which receives a file name as input and returns a priceFile as
outpput), I wrote:

wsdl:types
  xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema;
attributeFormDefault=qualified elementFormDefault=qualified
targetNamespace=http://quickstart.samples/xsd;
  xs:element name=getPriceFile
  xs:complexType
  xs:sequence
  xs:element name=priceFileName
nillable=true type=xs:string /
  /xs:sequence
  /xs:complexType
  /xs:element
  xs:element name=getPriceFileResponse
  xs:complexType
  xs:sequence
  xs:element name=priceFile
nillable=true type=xs:string /
  /xs:sequence
  /xs:complexType
  /xs:element


Is this correct?

Thanks
Michele



On 4/20/07, Michele Amoretti [EMAIL PROTECTED] wrote:


No, I tried this but the problem persists: only 24KB of the file are
transferred from the service to the client. :(

Michele

On 4/19/07, Masin, Valerie [EMAIL PROTECTED] wrote:

 A colleague had this problem (when using Sun's webserver) and fixed it
 by setting this on the client.
 stub._getServiceClient().getOptions().setProperty(
 HTTPConstants.CHUNKED,
 Constants.VALUE_FALSE);

 I don't know if there is a way to say the same thing from the server, or
 if it is even necessary. The reason had something to do with whether the
 length was being passed. Sorry I am vague but this didn't happen directly to
 me so I don't know the exact particulars.

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
 Behalf Of Michele Amoretti
 Sent: Thursday, April 19, 2007 8:50 AM
 To: axis-user@ws.apache.org
 Subject: Re: using MTOM in a AXIOM-based WS

 Ok, it is setProperty()

 Now I managed to transfer a file from the service to the client, but if
 I try to transfer a file  23963 Bytes, the file is cut.

 Should I make some adjustments in axis2.xml, or in Tomcat configuration?

 I tried to enable caching both at the server side and at the client
 side, as explained in the tutorial:
options.setProperty (
 Constants.Configuration.CACHE_ATTACHMENTS,Constants.VALUE_TRUE);
 options.setProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR,
 C://axisTemp);
 options.setProperty(Constants.Configuration.FILE_SIZE_THRESHOLD ,
 4);

 but with these lines, the client blocks immediately when trying to
 invoke any operation of the service (not only the one involving the file
 transfer..).

 Any idea?

 Thanks


 On 4/18/07, Masin, Valerie [EMAIL PROTECTED] wrote:
  I believe it is setProperty(), not set() on the options object
 
  -Original Message-
  From: Michele Amoretti [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, April 18, 2007 1:24 PM
  To: axis-user@ws.apache.org
  Subject: using MTOM in a AXIOM-based WS
 
  Hello,
 
  I am trying to create a new version of the quickstartaxiom sample,
 with the StockQuoteService providing a getPriceFile operation which returns
 a file using MTOM.
 
  In the MTOM tutorial unfortunately there are only parts of code (I
 cannot find a complete example in axis2-1.1.1 - the mtom sample is not
 based on AXIOM) thus I had to write the other parts, but since I have some
 problems in invoking the service I think I have made a mistake somewhere.
 
 
  My new ***AXIOMClient*** should set
 
  options.set(Constants.Configuration.ENABLE_MTOM,
  Constants.VALUE_TRUE);
 
  as explained in the tutorial, but the Options class has no set
  method and I cannot find the right one..
 
  Btw, I added to the client the following method:
 
 public static OMElement getPriceFilePayload(String priceFileName) {
  OMFactory fac = OMAbstractFactory.getOMFactory();
  OMNamespace omNs = fac.createOMNamespace(
 
  http://quickstart.samples/xsd;, tns);
 
  OMElement method = fac.createOMElement(getPriceFile, omNs);
  OMElement value = fac.createOMElement(priceFileName, omNs);
  value.addChild(fac.createOMText(value, priceFileName));
  method.addChild(value);
  return method;
  }
 
  and in the main() method of the client I added the following part, for
 getFilePrice invocation:
 
  OMElement getPriceFilePayload = getPriceFilePayload(
 prova.txt

Re: using MTOM in a AXIOM-based WS

2007-04-20 Thread Thilina Gunarathne

I have question about the WSDL for the MTOM-based service... For the
operation which has a parameter which is a binary file, which type
should I declare for the parameter? string?

base64Binary..
You may refer to here[1] as a guide...

Thanks,
Thilina

[1] http://ws.apache.org/axis2/1_1_1/mtom-guide.html#25


In my enhanced StockQuoteservice.wsdl (which has a getPriceFile method
which receives a file name as input and returns a priceFile as
outpput), I wrote:

wsdl:types
xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema;
attributeFormDefault=qualified elementFormDefault=qualified
targetNamespace=http://quickstart.samples/xsd;
xs:element name=getPriceFile
xs:complexType
xs:sequence
xs:element name=priceFileName nillable=true 
type=xs:string /
/xs:sequence
/xs:complexType
/xs:element
xs:element name=getPriceFileResponse
xs:complexType
xs:sequence
xs:element name=priceFile nillable=true 
type=xs:string /
/xs:sequence
/xs:complexType
/xs:element


Is this correct?

Thank you very much



 
[1]http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/deprecated/mtomsample/
 [2]ws.apache.org/commons/tcpmon
 --
 Thilina Gunarathne  -  http://www.wso2.com - http://thilinag.blogspot.com

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




--
Michele Amoretti, Ph.D.
Distributed Systems Group
Dipartimento di Ingegneria dell'Informazione
Università degli Studi di Parma
http://www.ce.unipr.it/amoretti

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





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

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



Re: using MTOM in a AXIOM-based WS

2007-04-20 Thread Michele Amoretti

Yes I read the guide but I need a more complete example.


In my MTOM implementation I did not used a base64 encoded string.. I simply
did:

public OMElement getPriceFile(OMElement element) throws XMLStreamException {
   element.build();
   element.detach();

   OMElement fileNameElement = element.getFirstElement();
   String fileName = C:\\Programmi\\ + fileNameElement.getText();

   System.out.println(fileName =  + fileName);

   OMFactory fac = OMAbstractFactory.getOMFactory();
   OMNamespace omNs =
   fac.createOMNamespace(http://quickstart.samples/xsd;, ns);
   OMElement fileElement = fac.createOMElement(file, omNs);

   FileDataSource dataSource =
   new FileDataSource(fileName);

   DataHandler dataHandler = new DataHandler(dataSource);

   // create an OMText node with the above DataHandler and set
optimized to true
   OMText textData = fac.createOMText(dataHandler, true);

   fileElement.addChild(textData);

   OMElement response = fac.createOMElement(getPriceFileResponse,
omNs);
   OMElement priceFile = fac.createOMElement(priceFile, omNs);
   priceFile.addChild(textData);
   response.addChild(priceFile);

   return response;
   }

And it does work wheter I transfer a txt, a pdf, a jpg..

The WSDL currently defines:

   xs:element name=getPriceFileResponse
   xs:complexType
   xs:sequence
   xs:element name=priceFile nillable=true
type=xs:string /
   /xs:sequence
   /xs:complexType
   /xs:element

Is this bad?

Thanks


On 4/20/07, Thilina Gunarathne [EMAIL PROTECTED] wrote:


 I have question about the WSDL for the MTOM-based service... For the
 operation which has a parameter which is a binary file, which type
 should I declare for the parameter? string?
base64Binary..
You may refer to here[1] as a guide...

Thanks,
Thilina

[1] http://ws.apache.org/axis2/1_1_1/mtom-guide.html#25

 In my enhanced StockQuoteservice.wsdl (which has a getPriceFile method
 which receives a file name as input and returns a priceFile as
 outpput), I wrote:

 wsdl:types
 xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema;
 attributeFormDefault=qualified elementFormDefault=qualified
 targetNamespace=http://quickstart.samples/xsd;
 xs:element name=getPriceFile
 xs:complexType
 xs:sequence
 xs:element name=priceFileName
nillable=true type=xs:string /
 /xs:sequence
 /xs:complexType
 /xs:element
 xs:element name=getPriceFileResponse
 xs:complexType
 xs:sequence
 xs:element name=priceFile
nillable=true type=xs:string /
 /xs:sequence
 /xs:complexType
 /xs:element


 Is this correct?

 Thank you very much


 
 
[1]http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/deprecated/mtomsample/
  [2]ws.apache.org/commons/tcpmon
  --
  Thilina Gunarathne  -  http://www.wso2.com -
http://thilinag.blogspot.com
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 


 --
 Michele Amoretti, Ph.D.
 Distributed Systems Group
 Dipartimento di Ingegneria dell'Informazione
 Università degli Studi di Parma
 http://www.ce.unipr.it/amoretti

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




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

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





--
Michele Amoretti, Ph.D.
Distributed Systems Group
Dipartimento di Ingegneria dell'Informazione
Università degli Studi di Parma
http://www.ce.unipr.it/amoretti


Re: using MTOM in a AXIOM-based WS

2007-04-20 Thread Thilina Gunarathne

Yes I read the guide but I need a more complete example.

You can have a look at the MTOM Sample in the Axis2 dist.. It contains
a complete WSDL first sample...


In my MTOM implementation I did not used a base64 encoded string.. I simply
did:

You do not necessarily need to use base64 strings...  MTOM optimised
binary data is  represented by the base64Bianry data type...


From the MTOM spec,

At the conceptual level, this binary data can be thought of as being
base64-encoded in the XML Document. As this conceptual form might be
needed during some processing of the XML Document (e.g., for signing
the XML document), it is necessary to have a one-to-one correspondence
between XML Infosets and XOP Packages. Therefore, the conceptual
representation of such binary data is as if it were base64-encoded,
using the canonical lexical form of XML Schema base64Binary datatype
(see [XML Schema Part 2: Datatypes Second Edition] 3.2.16
base64Binary). In the reverse direction, XOP is capable of optimizing
only base64-encoded Infoset data that is in the canonical lexical
form.


 And it does work wheter I transfer a txt, a pdf, a jpg..

The WSDL currently defines:

xs:element name=getPriceFileResponse
xs:complexType
xs:sequence
xs:element name=priceFile nillable=true
type=xs:string /

this needs to be xs:base64Binary...

Thanks,
Thilina


Is this bad?

Thanks



On 4/20/07, Thilina Gunarathne [EMAIL PROTECTED] wrote:

  I have question about the WSDL for the MTOM-based service... For the
  operation which has a parameter which is a binary file, which type
  should I declare for the parameter? string?
 base64Binary..
 You may refer to here[1] as a guide...

 Thanks,
 Thilina

 [1] http://ws.apache.org/axis2/1_1_1/mtom-guide.html#25
 
  In my enhanced StockQuoteservice.wsdl (which has a getPriceFile method
  which receives a file name as input and returns a priceFile as
  outpput), I wrote:
 
  wsdl:types
  xs:schema xmlns:xs=
http://www.w3.org/2001/XMLSchema;
  attributeFormDefault=qualified
elementFormDefault=qualified
  targetNamespace= http://quickstart.samples/xsd;
  xs:element name=getPriceFile
  xs:complexType
  xs:sequence
  xs:element
name=priceFileName nillable=true type=xs:string /
  /xs:sequence
  /xs:complexType
  /xs:element
  xs:element name=getPriceFileResponse
  xs:complexType
  xs:sequence
  xs:element
name=priceFile nillable=true type=xs:string /
  /xs:sequence
  /xs:complexType
  /xs:element
 
 
  Is this correct?
 
  Thank you very much
 
 
  
  
[1]http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/deprecated/mtomsample/
   [2]ws.apache.org/commons/tcpmon
   --
   Thilina Gunarathne  -  http://www.wso2.com -
http://thilinag.blogspot.com
  
  
-
   To unsubscribe, e-mail:
[EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
 
  --
  Michele Amoretti, Ph.D.
  Distributed Systems Group
  Dipartimento di Ingegneria dell'Informazione
  Università degli Studi di Parma
  http://www.ce.unipr.it/amoretti
 
 
-
  To unsubscribe, e-mail:
[EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 


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


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





--
Michele Amoretti, Ph.D.
Distributed Systems Group
Dipartimento di Ingegneria dell'Informazione
Università degli Studi di Parma
 http://www.ce.unipr.it/amoretti



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

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



RE: using MTOM in a AXIOM-based WS

2007-04-20 Thread Masin, Valerie
To really know that you are using MTOM you should be looking at your soap 
messages with tcpmon. If you are not using MTOM but are using base64Binary your 
soap will look something like this. Notice the ns1:document tag contains an 
encoded document directly embedded. 

POST /axis2/services/DocHarborServices HTTP/1.1
SOAPAction: urn:importDocument
User-Agent: Axis2
Host: 127.0.0.1:30004
Content-Length: changed since I reduced this file
Content-Type: text/xml; charset=UTF-8

?xml version='1.0' encoding='UTF-8'?
   soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/;
  soapenv:Header /
  soapenv:Body
 ns1:importDocument xmlns:ns1=urn:webservices.docharbor.com
ns1:users
   ns1:usernameuser1/ns1:username
   ns1:groupNamefoldergroup/ns1:groupName
/ns1:users

ns1:documente1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcZGVmbGFuZzEwMzN7XGZvbnR0Ymx7XGYwXGZzd2lzc1xmY2hhcnNldDAgQXJpYWw7fX0NCntcKlxnZW5lcmF0b3IgTXNmdGVkaXQgNS40MS4xNS4xNTA3O31cdmlld2tpbmQ0XHVjMVxwYXJkXGYwXGZzMjAgSSdtIHRoZSBkZWZhdWx0IGRvY3VtZW50IGZvciBpbXBvcnRhdGlvbi5ccGFyDQp9DQoA/ns1:document
 /ns1:importDocument
  /soapenv:Body
   /soapenv:Envelope


If you are using MTOM, the same message will look like this. Notice the 
reference to the multipart mime in the ns1:document tag. The document is not 
encoded. The bytes appear directly (it is a MS word doc)
POST /axis2/services/DocHarborServices HTTP/1.1
SOAPAction: urn:importDocument
User-Agent: Axis2
Host: 127.0.0.1:30004
Content-Length: changed since I reduced this file
Content-Type: multipart/related; 
boundary=MIMEBoundaryurn_uuid_C6B9C73E6321C6820C1175004575367; 
type=application/xop+xml; start=0.urn:uuid:[EMAIL PROTECTED]; 
start-info=text/xml; 
charset=UTF-8--MIMEBoundaryurn_uuid_C6B9C73E6321C6820C1175004575367content-type:
 application/xop+xml; charset=UTF-8; type=text/xml;content-transfer-encoding: 
binarycontent-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
   ns1:importDocument xmlns:ns1=urn:webservices.docharbor.com
  ns1:users
 ns1:usernameuser1/ns1:username
 ns1:groupNamefoldergroup/ns1:groupName
  /ns1:users
  ns1:document
 xop:Include href=cid:1.urn:uuid:[EMAIL PROTECTED] 
xmlns:xop=http://www.w3.org/2004/08/xop/include; /
  /ns1:document
   /ns1:importDocument
/soapenv:Body
 
/soapenv:Envelope--MIMEBoundaryurn_uuid_C6B9C73E6321C6820C1175004575367content-type:
 application/octet-streamcontent-transfer-encoding: binarycontent-id: 
 1.urn:uuid:[EMAIL 
PROTECTED]{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0
 Arial;}}{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 I'm 
the default document for importation.\par}
 

-Original Message-
From: Thilina Gunarathne [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 20, 2007 4:38 AM
To: axis-user@ws.apache.org
Subject: Re: using MTOM in a AXIOM-based WS

 Yes I read the guide but I need a more complete example.
You can have a look at the MTOM Sample in the Axis2 dist.. It contains a 
complete WSDL first sample...

 In my MTOM implementation I did not used a base64 encoded string.. I 
 simply
 did:
You do not necessarily need to use base64 strings...  MTOM optimised binary 
data is  represented by the base64Bianry data type...

From the MTOM spec,
At the conceptual level, this binary data can be thought of as being 
base64-encoded in the XML Document. As this conceptual form might be needed 
during some processing of the XML Document (e.g., for signing the XML 
document), it is necessary to have a one-to-one correspondence between XML 
Infosets and XOP Packages. Therefore, the conceptual representation of such 
binary data is as if it were base64-encoded, using the canonical lexical form 
of XML Schema base64Binary datatype (see [XML Schema Part 2: Datatypes Second 
Edition] 3.2.16 base64Binary). In the reverse direction, XOP is capable of 
optimizing only base64-encoded Infoset data that is in the canonical lexical 
form.

  And it does work wheter I transfer a txt, a pdf, a jpg..

 The WSDL currently defines:

 xs:element name=getPriceFileResponse
 xs:complexType
 xs:sequence
 xs:element name=priceFile nillable=true
 type=xs:string /
this needs to be xs:base64Binary...

Thanks,
Thilina

 Is this bad?

 Thanks



 On 4/20/07, Thilina Gunarathne [EMAIL PROTECTED] wrote:
 
   I have question about the WSDL for the MTOM-based service... For 
   the operation which has a parameter which is a binary file, which 
   type should I declare for the parameter? string?
  base64Binary..
  You may refer to here[1

Re: using MTOM in a AXIOM-based WS

2007-04-19 Thread Thilina Gunarathne

Hi,


In the MTOM tutorial unfortunately there are only parts of code (I
cannot find a complete example in axis2-1.1.1 - the mtom sample is not
based on AXIOM)

You can find a rather complicated deprecated MTOM Sample based on
Axiom in here[1].

options.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);

As Valerie mentioned this should be setProperty...

But AFAIKS you are trying to return an attachment from a server.. For
that you need to enable MTOM in the server side by adding the
following parameter to your axis2.xml or to the service.xml..
parameter name=enableMTOM locked=falsetrue/parameter


Is this ok? Where should I store the prova.txt file in the server?

You can try giving an absolute path...

Please use the TCPMON[2] to capture your messages and check whether
the attachment is attached as a MIME part.

Thanks,
Thilina

[1]http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/deprecated/mtomsample/
[2]ws.apache.org/commons/tcpmon
--
Thilina Gunarathne  -  http://www.wso2.com - http://thilinag.blogspot.com

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



Re: using MTOM in a AXIOM-based WS

2007-04-19 Thread Michele Amoretti

Thank you, please read the comments below:

On 4/19/07, Thilina Gunarathne [EMAIL PROTECTED] wrote:

Hi,

 In the MTOM tutorial unfortunately there are only parts of code (I
 cannot find a complete example in axis2-1.1.1 - the mtom sample is not
 based on AXIOM)
You can find a rather complicated deprecated MTOM Sample based on
Axiom in here[1].


Ok I will study this.


 options.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
As Valerie mentioned this should be setProperty...


Ok



But AFAIKS you are trying to return an attachment from a server.. For
that you need to enable MTOM in the server side by adding the
following parameter to your axis2.xml or to the service.xml..
parameter name=enableMTOM locked=falsetrue/parameter



Yes I did it!


 Is this ok? Where should I store the prova.txt file in the server?
You can try giving an absolute path...


Ok



Please use the TCPMON[2] to capture your messages and check whether
the attachment is attached as a MIME part.

Thanks,
Thilina



I have question about the WSDL for the MTOM-based service... For the
operation which has a parameter which is a binary file, which type
should I declare for the parameter? string?

In my enhanced StockQuoteservice.wsdl (which has a getPriceFile method
which receives a file name as input and returns a priceFile as
outpput), I wrote:

wsdl:types
xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema;
attributeFormDefault=qualified elementFormDefault=qualified
targetNamespace=http://quickstart.samples/xsd;
xs:element name=getPriceFile
xs:complexType
xs:sequence
xs:element name=priceFileName nillable=true 
type=xs:string /
/xs:sequence
/xs:complexType
/xs:element
xs:element name=getPriceFileResponse
xs:complexType
xs:sequence
xs:element name=priceFile nillable=true 
type=xs:string /
/xs:sequence
/xs:complexType
/xs:element


Is this correct?

Thank you very much




[1]http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/deprecated/mtomsample/
[2]ws.apache.org/commons/tcpmon
--
Thilina Gunarathne  -  http://www.wso2.com - http://thilinag.blogspot.com

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





--
Michele Amoretti, Ph.D.
Distributed Systems Group
Dipartimento di Ingegneria dell'Informazione
Università degli Studi di Parma
http://www.ce.unipr.it/amoretti

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



Re: using MTOM in a AXIOM-based WS

2007-04-19 Thread Michele Amoretti

Ok, it is setProperty()

Now I managed to transfer a file from the service to the client, but
if I try to transfer a file  23963 Bytes, the file is cut.

Should I make some adjustments in axis2.xml, or in Tomcat configuration?

I tried to enable caching both at the server side and at the client
side, as explained in the tutorial:
  
options.setProperty(Constants.Configuration.CACHE_ATTACHMENTS,Constants.VALUE_TRUE);
options.setProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR,
C://axisTemp);
options.setProperty(Constants.Configuration.FILE_SIZE_THRESHOLD, 4);

but with these lines, the client blocks immediately when trying to
invoke any operation of the service (not only the one involving the
file transfer..).

Any idea?

Thanks


On 4/18/07, Masin, Valerie [EMAIL PROTECTED] wrote:

I believe it is setProperty(), not set() on the options object

-Original Message-
From: Michele Amoretti [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 18, 2007 1:24 PM
To: axis-user@ws.apache.org
Subject: using MTOM in a AXIOM-based WS

Hello,

I am trying to create a new version of the quickstartaxiom sample, with the 
StockQuoteService providing a getPriceFile operation which returns a file using MTOM.

In the MTOM tutorial unfortunately there are only parts of code (I cannot find 
a complete example in axis2-1.1.1 - the mtom sample is not based on AXIOM) thus 
I had to write the other parts, but since I have some problems in invoking the 
service I think I have made a mistake somewhere.


My new ***AXIOMClient*** should set

options.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);

as explained in the tutorial, but the Options class has no set
method and I cannot find the right one..

Btw, I added to the client the following method:

   public static OMElement getPriceFilePayload(String priceFileName) {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace(

http://quickstart.samples/xsd;, tns);

OMElement method = fac.createOMElement(getPriceFile, omNs);
OMElement value = fac.createOMElement(priceFileName, omNs);
value.addChild(fac.createOMText(value, priceFileName));
method.addChild(value);
return method;
}

and in the main() method of the client I added the following part, for 
getFilePrice invocation:

OMElement getPriceFilePayload = getPriceFilePayload(prova.txt); 
...
result = sender.sendReceive(getPriceFilePayload);
OMElement ele = result.getFirstElement();
OMText binaryNode = (OMText) ele.getFirstOMChild();
DataHandler actualDH = (DataHandler) binaryNode.getDataHandler();
File file = new File(prova.txt);
FileOutputStream fileOutputStream = new FileOutputStream(file);
actualDH.writeTo(fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();



In the ***StockQuoteService*** the getPriceFile method is implemented as 
follows:


 public OMElement getPriceFile(OMElement element) throws XMLStreamException {
element.build();
element.detach();

OMElement fileNameElement = element.getFirstElement();
String fileName = fileNameElement.getText();

System.out.println(fileName =  + fileName);

OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs =
fac.createOMNamespace(http://quickstart.samples/xsd;, ns);
OMElement fileElement = fac.createOMElement(file, omNs);

FileDataSource dataSource =
new FileDataSource(fileName);

DataHandler dataHandler = new DataHandler(dataSource);

// create an OMText node with the above DataHandler and set optimized 
to true
OMText textData = fac.createOMText(dataHandler, true);

fileElement.addChild(textData);

OMElement method = fac.createOMElement(getPriceFileResponse, omNs);
OMElement value = fac.createOMElement(priceFile, omNs);
value.addChild(textData);
method.addChild(value);

return method;
}


Is this ok? Where should I store the prova.txt file in the server?
In the same folder in which I put the *.aar file?

I attach to this mail the wsdl of the service, and the configuration file.


I am using Tomcat as servlet engine, and the logs are clean at the server side.

At the client side the error message is:

[java] org.apache.axiom.om.OMException: Referenced Attachment not found in 
the MIME Message.
ContentID:1.urn:uuid:[EMAIL PROTECTED]
 [java] at 
org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder.getDataHandler(MTOMStAXSOAPModelBuilder.java:107)
 [java] at 
org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:379)
 [java] at samples.quickstart.clients.AXIOMClient.main(AXIOMClient.java:105)
 [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [java] at 

RE: using MTOM in a AXIOM-based WS

2007-04-19 Thread Masin, Valerie
A colleague had this problem (when using Sun's webserver) and fixed it by 
setting this on the client.
stub._getServiceClient().getOptions().setProperty(
HTTPConstants.CHUNKED, Constants.VALUE_FALSE);
 
I don't know if there is a way to say the same thing from the server, or if it 
is even necessary. The reason had something to do with whether the length was 
being passed. Sorry I am vague but this didn't happen directly to me so I don't 
know the exact particulars.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michele Amoretti
Sent: Thursday, April 19, 2007 8:50 AM
To: axis-user@ws.apache.org
Subject: Re: using MTOM in a AXIOM-based WS

Ok, it is setProperty()

Now I managed to transfer a file from the service to the client, but if I try 
to transfer a file  23963 Bytes, the file is cut.

Should I make some adjustments in axis2.xml, or in Tomcat configuration?

I tried to enable caching both at the server side and at the client side, as 
explained in the tutorial:
   
options.setProperty(Constants.Configuration.CACHE_ATTACHMENTS,Constants.VALUE_TRUE);
options.setProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR,
C://axisTemp);
options.setProperty(Constants.Configuration.FILE_SIZE_THRESHOLD, 4);

but with these lines, the client blocks immediately when trying to invoke any 
operation of the service (not only the one involving the file transfer..).

Any idea?

Thanks


On 4/18/07, Masin, Valerie [EMAIL PROTECTED] wrote:
 I believe it is setProperty(), not set() on the options object

 -Original Message-
 From: Michele Amoretti [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, April 18, 2007 1:24 PM
 To: axis-user@ws.apache.org
 Subject: using MTOM in a AXIOM-based WS

 Hello,

 I am trying to create a new version of the quickstartaxiom sample, with the 
 StockQuoteService providing a getPriceFile operation which returns a file 
 using MTOM.

 In the MTOM tutorial unfortunately there are only parts of code (I cannot 
 find a complete example in axis2-1.1.1 - the mtom sample is not based on 
 AXIOM) thus I had to write the other parts, but since I have some problems in 
 invoking the service I think I have made a mistake somewhere.


 My new ***AXIOMClient*** should set

 options.set(Constants.Configuration.ENABLE_MTOM, 
 Constants.VALUE_TRUE);

 as explained in the tutorial, but the Options class has no set
 method and I cannot find the right one..

 Btw, I added to the client the following method:

public static OMElement getPriceFilePayload(String priceFileName) {
 OMFactory fac = OMAbstractFactory.getOMFactory();
 OMNamespace omNs = fac.createOMNamespace(

 http://quickstart.samples/xsd;, tns);

 OMElement method = fac.createOMElement(getPriceFile, omNs);
 OMElement value = fac.createOMElement(priceFileName, omNs);
 value.addChild(fac.createOMText(value, priceFileName));
 method.addChild(value);
 return method;
 }

 and in the main() method of the client I added the following part, for 
 getFilePrice invocation:

 OMElement getPriceFilePayload = getPriceFilePayload(prova.txt); 
 ...
 result = sender.sendReceive(getPriceFilePayload);
 OMElement ele = result.getFirstElement();
 OMText binaryNode = (OMText) ele.getFirstOMChild();
 DataHandler actualDH = (DataHandler) binaryNode.getDataHandler();
 File file = new File(prova.txt);
 FileOutputStream fileOutputStream = new FileOutputStream(file);
 actualDH.writeTo(fileOutputStream);
 fileOutputStream.flush();
 fileOutputStream.close();



 In the ***StockQuoteService*** the getPriceFile method is implemented as 
 follows:


  public OMElement getPriceFile(OMElement element) throws XMLStreamException {
 element.build();
 element.detach();

 OMElement fileNameElement = element.getFirstElement();
 String fileName = fileNameElement.getText();

 System.out.println(fileName =  + fileName);

 OMFactory fac = OMAbstractFactory.getOMFactory();
 OMNamespace omNs =
 fac.createOMNamespace(http://quickstart.samples/xsd;, ns);
 OMElement fileElement = fac.createOMElement(file, omNs);

 FileDataSource dataSource =
 new FileDataSource(fileName);

 DataHandler dataHandler = new DataHandler(dataSource);

 // create an OMText node with the above DataHandler and set optimized 
 to true
 OMText textData = fac.createOMText(dataHandler, true);

 fileElement.addChild(textData);

 OMElement method = fac.createOMElement(getPriceFileResponse, omNs);
 OMElement value = fac.createOMElement(priceFile, omNs);
 value.addChild(textData);
 method.addChild(value);

 return method;
 }


 Is this ok? Where should I store the prova.txt

RE: using MTOM in a AXIOM-based WS

2007-04-18 Thread Masin, Valerie
I believe it is setProperty(), not set() on the options object 

-Original Message-
From: Michele Amoretti [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 18, 2007 1:24 PM
To: axis-user@ws.apache.org
Subject: using MTOM in a AXIOM-based WS

Hello,

I am trying to create a new version of the quickstartaxiom sample, with the 
StockQuoteService providing a getPriceFile operation which returns a file using 
MTOM.

In the MTOM tutorial unfortunately there are only parts of code (I cannot find 
a complete example in axis2-1.1.1 - the mtom sample is not based on AXIOM) thus 
I had to write the other parts, but since I have some problems in invoking the 
service I think I have made a mistake somewhere.


My new ***AXIOMClient*** should set

options.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);

as explained in the tutorial, but the Options class has no set
method and I cannot find the right one..

Btw, I added to the client the following method:

   public static OMElement getPriceFilePayload(String priceFileName) {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace(

http://quickstart.samples/xsd;, tns);

OMElement method = fac.createOMElement(getPriceFile, omNs);
OMElement value = fac.createOMElement(priceFileName, omNs);
value.addChild(fac.createOMText(value, priceFileName));
method.addChild(value);
return method;
}

and in the main() method of the client I added the following part, for 
getFilePrice invocation:

OMElement getPriceFilePayload = getPriceFilePayload(prova.txt); 
...
result = sender.sendReceive(getPriceFilePayload);
OMElement ele = result.getFirstElement();
OMText binaryNode = (OMText) ele.getFirstOMChild();
DataHandler actualDH = (DataHandler) binaryNode.getDataHandler();
File file = new File(prova.txt);
FileOutputStream fileOutputStream = new FileOutputStream(file);
actualDH.writeTo(fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();



In the ***StockQuoteService*** the getPriceFile method is implemented as 
follows:


 public OMElement getPriceFile(OMElement element) throws XMLStreamException {
element.build();
element.detach();

OMElement fileNameElement = element.getFirstElement();
String fileName = fileNameElement.getText();

System.out.println(fileName =  + fileName);

OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs =
fac.createOMNamespace(http://quickstart.samples/xsd;, ns);
OMElement fileElement = fac.createOMElement(file, omNs);

FileDataSource dataSource =
new FileDataSource(fileName);

DataHandler dataHandler = new DataHandler(dataSource);

// create an OMText node with the above DataHandler and set optimized 
to true
OMText textData = fac.createOMText(dataHandler, true);

fileElement.addChild(textData);

OMElement method = fac.createOMElement(getPriceFileResponse, omNs);
OMElement value = fac.createOMElement(priceFile, omNs);
value.addChild(textData);
method.addChild(value);

return method;
}


Is this ok? Where should I store the prova.txt file in the server?
In the same folder in which I put the *.aar file?

I attach to this mail the wsdl of the service, and the configuration file.


I am using Tomcat as servlet engine, and the logs are clean at the server side.

At the client side the error message is:

[java] org.apache.axiom.om.OMException: Referenced Attachment not found in 
the MIME Message.
ContentID:1.urn:uuid:[EMAIL PROTECTED]
 [java] at 
org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder.getDataHandler(MTOMStAXSOAPModelBuilder.java:107)
 [java] at 
org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:379)
 [java] at samples.quickstart.clients.AXIOMClient.main(AXIOMClient.java:105)
 [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [java] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 [java] at java.lang.reflect.Method.invoke(Unknown Source)
 [java] at 
org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:202)
 [java] at 
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:134)
 [java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:710)
 [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:178)
 [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:84)
 [java] at 
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
 [java] at org.apache.tools.ant.Task.perform(Task.java:364)
 [java] at org.apache.tools.ant.Target.execute(Target.java:341)