You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Nathan Kuroczycki <ku...@gmail.com> on 2007/01/17 14:50:40 UTC
Sending MTOM attachments from Axis2 client
Hi,
I am trying to send the request XML with the binary within an MTOM
attachment. However, the code below sends the binary inline with the rest of
the xml request. My understanding from the Axis2 examples is that by
enabling MTOM, the binary will be sent as a referenced attachment. Is there
something that I'm not doing?
Thanks,
Nathan
ServiceClient service = *new* ServiceClient();
Options options = *new* Options();
options.setTo(*new* EndpointReference(*URL*));
options.setAction("urn:update");
options.setProperty(Constants.Configuration.*ENABLE_MTOM*, Constants.*
VALUE_TRUE*);
service.setOptions(options);
*try* {
OMFactory fac = OMAbstractFactory.*getOMFactory*();
OMNamespace omNs = fac.createOMNamespace("catalog", "");
OMElement up = fac.createOMElement("in0", omNs);
FileDataSource fds = *new* FileDataSource("file.xml");
DataHandler dataHandler = *new* DataHandler(fds);
OMText textData = fac.createOMText(dataHandler, *true*);
textData.setOptimize(*true*);
up.addChild(textData);
//OMElement res = service.sendReceive(up);
//service.fireAndForget(up);
service.sendRobust(up);
}
*catch*(Exception error) {
error.printStackTrace();
}
Re: Sending MTOM attachments from Axis2 client
Posted by Nathan Kuroczycki <ku...@gmail.com>.
Hi Thilina,
the message snapshot from TCPmon is as follows...
POST /CatalogWebService/services/CatalogWebService HTTP/1.1
SOAPAction: "
http://www.domain.com/bwe/webservices/catalog/CatalogWebServicePortType/updateRequest
"
User-Agent: Axis2
Host: localhost:6060
Transfer-Encoding: chunked
Content-Type: multipart/related;
boundary=MIMEBoundaryurn_uuid_5100F094B022EB458111695441501391;
type="application/xop+xml"; start="<
0.urn:uuid:5100F094B022EB458111695441501392@apache.org>";
start-info="text/xml"; charset=UTF-8
59f
--MIMEBoundaryurn_uuid_5100F094B022EB458111695441501391
content-type: application/xop+xml; charset=UTF-8; type="text/xml";
content-transfer-encoding: binary
content-id: <0....@apache.org>
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header>
<wsse:Security xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
soapenv:mustUnderstand="1"><wsse:UsernameToken xmlns:wsu="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
wsu:Id="UsernameToken-28349544"><wsse:Username>username01</wsse:Username><wsse:Password
Type="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password01</wsse:Password></wsse:UsernameToken></wsse:Security></soapenv:Header><soapenv:Body><ns4:updatexmlns:ns4="
http://www.domain.com/bwe/webservices/catalog"><in0 xmlns="
http://www.domain.com/bwe/webservices/catalog">PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxiYXRjaCB4bWxucz0iaHR0cDovL3d3dy5pZGJzLmNvbS9ld2IvY2F0YWxvZy9yZXF1ZXN0IiB4bWxuczpjYXQ9Imh0dHA6Ly93d3cuaWRicy5jb20vZXdiL2NhdGFsb2cvcmVxdWVzdCI+IA0KICA8Y2F0OmRlbGV0ZSBwYXRoPSIvVGVzdCAwMi8iLz4NCiAgPGNhdDpkZWxldGUgcGF0aD0iL1Rlc3QgMDJiLyIvPg0KPC9iYXRjaD4g</in0></ns4:update></soapenv:Body></soapenv:Envelope
>
--MIMEBoundaryurn_uuid_5100F094B022EB458111695441501391--
0
Thanks,
Nathan
On 1/20/07, Thilina Gunarathne <cs...@gmail.com> wrote:
>
> Can you see the Mime boundaries...
> If possible please post the message snapshot..
>
> ~Thilina
>
> On 1/17/07, Nathan Kuroczycki <ku...@gmail.com> wrote:
> > Angel,
> >
> > I observed that behaviour using TCPMon.
> >
> > Nathan
> >
> >
> >
> >
> > On 1/17/07, Angel Todorov <at...@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > where do you observe that behavior ? Via the soap monitor or by using
> > > a TCP (HTTP more specifically) sniffer ? Normally to see if MTOM is
> > > working you should use some TCP monitor, soap monitor or any other
> > > soap message monitor won't help you.
> > >
> > > --Angel
> > >
> > > On 1/17/07, Nathan Kuroczycki <kuroczycki@gmail.com > wrote:
> > > > Hi,
> > > >
> > > > I am trying to send the request XML with the binary within an MTOM
> > > > attachment. However, the code below sends the binary inline with the
> > rest of
> > > > the xml request. My understanding from the Axis2 examples is that by
> > > > enabling MTOM, the binary will be sent as a referenced attachment.
> Is
> > there
> > > > something that I'm not doing?
> > > >
> > > > Thanks,
> > > > Nathan
> > > >
> > > >
> > > > ServiceClient service = new ServiceClient();
> > > >
> > > >
> > > >
> > > > Options options = new Options();
> > > >
> > > > options.setTo(new EndpointReference(URL));
> > > >
> > > > options.setAction("urn:update");
> > > >
> > > > options.setProperty(Constants.Configuration.ENABLE_MTOM
> > ,
> > > > Constants.VALUE_TRUE );
> > > >
> > > > service.setOptions(options);
> > > >
> > > >
> > > >
> > > > try {
> > > >
> > > >
> > > >
> > > > OMFactory fac = OMAbstractFactory.getOMFactory();
> > > >
> > > > OMNamespace omNs = fac.createOMNamespace("catalog", "");
> > > >
> > > > OMElement up = fac.createOMElement("in0", omNs);
> > > >
> > > >
> > > >
> > > > FileDataSource fds = new FileDataSource("file.xml");
> > > >
> > > > DataHandler dataHandler = new DataHandler(fds);
> > > >
> > > >
> > > >
> > > > OMText textData = fac.createOMText(dataHandler, true);
> > > >
> > > > textData.setOptimize(true);
> > > >
> > > >
> > > >
> > > > up.addChild(textData);
> > > >
> > > >
> > > >
> > > > //OMElement res = service.sendReceive(up);
> > > >
> > > > //service.fireAndForget(up);
> > > >
> > > > service.sendRobust(up);
> > > >
> > > > }
> > > >
> > > > catch(Exception error) {
> > > >
> > > > error.printStackTrace();
> > > >
> > > > }
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > axis-user-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: axis-user-help@ws.apache.org
> > >
> > >
> >
> >
>
>
> --
> Thilina Gunarathne
> WSO2, Inc.; http://www.wso2.com/
> Home page: http://webservices.apache.org/~thilina/
> Blog: 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
>
>
Re: Sending MTOM attachments from Axis2 client
Posted by Thilina Gunarathne <cs...@gmail.com>.
Can you see the Mime boundaries...
If possible please post the message snapshot..
~Thilina
On 1/17/07, Nathan Kuroczycki <ku...@gmail.com> wrote:
> Angel,
>
> I observed that behaviour using TCPMon.
>
> Nathan
>
>
>
>
> On 1/17/07, Angel Todorov <at...@gmail.com> wrote:
>
> > Hi,
> >
> > where do you observe that behavior ? Via the soap monitor or by using
> > a TCP (HTTP more specifically) sniffer ? Normally to see if MTOM is
> > working you should use some TCP monitor, soap monitor or any other
> > soap message monitor won't help you.
> >
> > --Angel
> >
> > On 1/17/07, Nathan Kuroczycki <kuroczycki@gmail.com > wrote:
> > > Hi,
> > >
> > > I am trying to send the request XML with the binary within an MTOM
> > > attachment. However, the code below sends the binary inline with the
> rest of
> > > the xml request. My understanding from the Axis2 examples is that by
> > > enabling MTOM, the binary will be sent as a referenced attachment. Is
> there
> > > something that I'm not doing?
> > >
> > > Thanks,
> > > Nathan
> > >
> > >
> > > ServiceClient service = new ServiceClient();
> > >
> > >
> > >
> > > Options options = new Options();
> > >
> > > options.setTo(new EndpointReference(URL));
> > >
> > > options.setAction("urn:update");
> > >
> > > options.setProperty(Constants.Configuration.ENABLE_MTOM
> ,
> > > Constants.VALUE_TRUE );
> > >
> > > service.setOptions(options);
> > >
> > >
> > >
> > > try {
> > >
> > >
> > >
> > > OMFactory fac = OMAbstractFactory.getOMFactory();
> > >
> > > OMNamespace omNs = fac.createOMNamespace("catalog", "");
> > >
> > > OMElement up = fac.createOMElement("in0", omNs);
> > >
> > >
> > >
> > > FileDataSource fds = new FileDataSource("file.xml");
> > >
> > > DataHandler dataHandler = new DataHandler(fds);
> > >
> > >
> > >
> > > OMText textData = fac.createOMText(dataHandler, true);
> > >
> > > textData.setOptimize(true);
> > >
> > >
> > >
> > > up.addChild(textData);
> > >
> > >
> > >
> > > //OMElement res = service.sendReceive(up);
> > >
> > > //service.fireAndForget(up);
> > >
> > > service.sendRobust(up);
> > >
> > > }
> > >
> > > catch(Exception error) {
> > >
> > > error.printStackTrace();
> > >
> > > }
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>
>
--
Thilina Gunarathne
WSO2, Inc.; http://www.wso2.com/
Home page: http://webservices.apache.org/~thilina/
Blog: 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
Re: Sending MTOM attachments from Axis2 client
Posted by Nathan Kuroczycki <ku...@gmail.com>.
Angel,
I observed that behaviour using TCPMon.
Nathan
On 1/17/07, Angel Todorov <at...@gmail.com> wrote:
> Hi,
>
> where do you observe that behavior ? Via the soap monitor or by using
> a TCP (HTTP more specifically) sniffer ? Normally to see if MTOM is
> working you should use some TCP monitor, soap monitor or any other
> soap message monitor won't help you.
>
> --Angel
>
> On 1/17/07, Nathan Kuroczycki <ku...@gmail.com> wrote:
> > Hi,
> >
> > I am trying to send the request XML with the binary within an MTOM
> > attachment. However, the code below sends the binary inline with the
> rest of
> > the xml request. My understanding from the Axis2 examples is that by
> > enabling MTOM, the binary will be sent as a referenced attachment. Is
> there
> > something that I'm not doing?
> >
> > Thanks,
> > Nathan
> >
> >
> > ServiceClient service = new ServiceClient();
> >
> >
> >
> > Options options = new Options();
> >
> > options.setTo(new EndpointReference(URL));
> >
> > options.setAction("urn:update");
> >
> > options.setProperty(Constants.Configuration.ENABLE_MTOM,
> > Constants.VALUE_TRUE );
> >
> > service.setOptions(options);
> >
> >
> >
> > try {
> >
> >
> >
> > OMFactory fac = OMAbstractFactory.getOMFactory();
> >
> > OMNamespace omNs = fac.createOMNamespace("catalog", "");
> >
> > OMElement up = fac.createOMElement("in0", omNs);
> >
> >
> >
> > FileDataSource fds = new FileDataSource("file.xml");
> >
> > DataHandler dataHandler = new DataHandler(fds);
> >
> >
> >
> > OMText textData = fac.createOMText(dataHandler, true);
> >
> > textData.setOptimize(true);
> >
> >
> >
> > up.addChild(textData);
> >
> >
> >
> > //OMElement res = service.sendReceive(up);
> >
> > //service.fireAndForget(up);
> >
> > service.sendRobust(up);
> >
> > }
> >
> > catch(Exception error) {
> >
> > error.printStackTrace();
> >
> > }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
Re: Sending MTOM attachments from Axis2 client
Posted by Angel Todorov <at...@gmail.com>.
Hi,
where do you observe that behavior ? Via the soap monitor or by using
a TCP (HTTP more specifically) sniffer ? Normally to see if MTOM is
working you should use some TCP monitor, soap monitor or any other
soap message monitor won't help you.
--Angel
On 1/17/07, Nathan Kuroczycki <ku...@gmail.com> wrote:
> Hi,
>
> I am trying to send the request XML with the binary within an MTOM
> attachment. However, the code below sends the binary inline with the rest of
> the xml request. My understanding from the Axis2 examples is that by
> enabling MTOM, the binary will be sent as a referenced attachment. Is there
> something that I'm not doing?
>
> Thanks,
> Nathan
>
>
> ServiceClient service = new ServiceClient();
>
>
>
> Options options = new Options();
>
> options.setTo(new EndpointReference(URL));
>
> options.setAction("urn:update");
>
> options.setProperty(Constants.Configuration.ENABLE_MTOM,
> Constants.VALUE_TRUE );
>
> service.setOptions(options);
>
>
>
> try {
>
>
>
> OMFactory fac = OMAbstractFactory.getOMFactory();
>
> OMNamespace omNs = fac.createOMNamespace("catalog", "");
>
> OMElement up = fac.createOMElement("in0", omNs);
>
>
>
> FileDataSource fds = new FileDataSource("file.xml");
>
> DataHandler dataHandler = new DataHandler(fds);
>
>
>
> OMText textData = fac.createOMText(dataHandler, true);
>
> textData.setOptimize(true);
>
>
>
> up.addChild(textData);
>
>
>
> //OMElement res = service.sendReceive(up);
>
> //service.fireAndForget(up);
>
> service.sendRobust(up);
>
> }
>
> catch(Exception error) {
>
> error.printStackTrace();
>
> }
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org