You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by robbywillz <wi...@nsn.com> on 2011/08/13 21:17:51 UTC

Convert Byte Array to Base64Binary

Hi,

I'm facing a problem in converting a Byte Array to Base64 Binary. 
The managerNonce supposed to be converted to Base64Binary format as it is
defined as byte[], but it converts to XOP format. The server expects this in
Base64Binary format.

Can you please help me on how to convert this to Base64 format?

I'm using Apache CXF 2.3.3 version.

--uuid:b151f053-b6cc-402f-a008-b1e2ca56dad1
Content-Type: text/xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: &lt;root.message@cxf.apache.org&gt;

<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><startRegistration
xmlns="http://www.nokiasiemens.com/ne3s/1.0"><managerIdentity><uniqueId>william_myne3s_test</uniqueId><type>ne3s_ws_client</type><vendor>NSN</vendor><release>1.0</release></managerIdentity><agentUniqueId>Esymac</agentUniqueId><notificationConsumerURL>http://localhost:7070/ne3sws/services</notificationConsumerURL><reRegisterInterval>10</reRegisterInterval>*<managerNonce><xop:Include
xmlns:xop="http://www.w3.org/2004/08/xop/include"
href="cid:0e2b6cc6-5048-4a46-b7c8-efb767126874-1@www.nokiasiemens.com"/></managerNonce>*<soc>4a6fa268-957f-4061-9f30-a2b51c0e570f@apache.org</soc></startRegistration></soap:Body></soap:Envelope>
--uuid:b151f053-b6cc-402f-a008-b1e2ca56dad1
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <0e...@www.nokiasiemens.com>

1313260562190


Regards,
William

--
View this message in context: http://cxf.547215.n5.nabble.com/Convert-Byte-Array-to-Base64Binary-tp4696903p4696903.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Convert Byte Array to Base64Binary

Posted by robbywillz <ro...@gmail.com>.
Hi Dan,

Thanks a lot for you response....

Regards,
William Rovinson


On Wed, Aug 24, 2011 at 2:09 AM, Daniel Kulp [via CXF] <
ml-node+4728189-1611002434-241202@n5.nabble.com> wrote:

> On Tuesday, August 16, 2011 11:28:43 PM robbywillz wrote:
>
> > Hi,
> >
> > Thanks a lot for providing different ways to enabling or disabling the
> MTOM.
> > I could able to have a inline Base64Binary by disabling the MTOM and
> > increasing the MTOM threshold(1024).
> > I understood that MTOM will be enabled for attachment when threshold is
> > crossed, even through MTOM is disabled. Please correct me if i'm wrong.
> >
> > Is there any way to configure through spring client configuration? I
> don't
> > want to make this changes in wsdl or in code as my code may run on
> Websphere
> > v6.1 with web services feature pack installed.
>
> If that's the case, I would actually suggest doing it in code, but with the
>
> standard JAX-WS API's.   That way, it should behave the same for any of the
>
> various JAX-WS providers.
>
> When you create your client, pass in a javax.xml.ws.soap.MTOMFeature object
>
> that is configured to turn off MTOM or set the threshold.   All the
> createXXXPort methods have an optional set of features that can be passed
> in
> at create time.   Use those methods with the MTOMFeature and it should work
>
> for WebSphere as well.
>
> Dan
>
>
>
> >
> > I've tried with following configuration and I named file as cxf.xml, it
> is
> > picked up by cxf but no effect on the configuration. It still converts to
>
> > XOP. Please help me?
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <beans xmlns="http://www.springframework.org/schema/beans"
> > xmlns:jaxws="http://cxf.apache.org/jaxws"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:schemaLocation="
> >           http://www.springframework.org/schema/beans
> >           http://www.springframework.org/schema/beans/spring-beans.xsd
> >           http://cxf.apache.org/jaxws
> >           http://cxf.apache.org/schemas/jaxws.xsd">
> >
> >
> > <jaxws:client id="ne3sRegistration"
> > serviceClass="com.nsn.oss.ne3s.ws.gen.NE3SRegistrationPort"
> > address="/NE3SRegistrationService">
> > <jaxws:properties>
> > <entry key="mtom-enabled" value="false" />
> > <entry key="mtom-threshold" value="1024" />
> > </jaxws:properties>
> > </jaxws:client>
> > </beans>
> >
> --
> Daniel Kulp
> [hidden email] <http://user/SendEmail.jtp?type=node&node=4728189&i=0>
> http://dankulp.com/blog
> Talend - http://www.talend.com
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://cxf.547215.n5.nabble.com/Convert-Byte-Array-to-Base64Binary-tp4696903p4728189.html
>  To unsubscribe from Convert Byte Array to Base64Binary, click here<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4696903&code=cm9iYnl3aWxsekBnbWFpbC5jb218NDY5NjkwM3wtMzc3MjI5ODU3>.
>
>


-----
Regards,
William Rovinson
--
View this message in context: http://cxf.547215.n5.nabble.com/Convert-Byte-Array-to-Base64Binary-tp4696903p4730987.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Convert Byte Array to Base64Binary

Posted by Daniel Kulp <dk...@apache.org>.
On Tuesday, August 16, 2011 11:28:43 PM robbywillz wrote:
> Hi,
> 
> Thanks a lot for providing different ways to enabling or disabling the MTOM.
> I could able to have a inline Base64Binary by disabling the MTOM and
> increasing the MTOM threshold(1024).
> I understood that MTOM will be enabled for attachment when threshold is
> crossed, even through MTOM is disabled. Please correct me if i'm wrong.
> 
> Is there any way to configure through spring client configuration? I don't
> want to make this changes in wsdl or in code as my code may run on Websphere
> v6.1 with web services feature pack installed.

If that's the case, I would actually suggest doing it in code, but with the 
standard JAX-WS API's.   That way, it should behave the same for any of the 
various JAX-WS providers.

When you create your client, pass in a javax.xml.ws.soap.MTOMFeature object 
that is configured to turn off MTOM or set the threshold.   All the 
createXXXPort methods have an optional set of features that can be passed in 
at create time.   Use those methods with the MTOMFeature and it should work 
for WebSphere as well.

Dan



> 
> I've tried with following configuration and I named file as cxf.xml, it is
> picked up by cxf but no effect on the configuration. It still converts to
> XOP. Please help me?
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:jaxws="http://cxf.apache.org/jaxws"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xsi:schemaLocation="
>           http://www.springframework.org/schema/beans
>           http://www.springframework.org/schema/beans/spring-beans.xsd
>           http://cxf.apache.org/jaxws
>           http://cxf.apache.org/schemas/jaxws.xsd">
> 
> 
> 	<jaxws:client id="ne3sRegistration"
> 		serviceClass="com.nsn.oss.ne3s.ws.gen.NE3SRegistrationPort"
> address="/NE3SRegistrationService">
> 		<jaxws:properties>
> 			<entry key="mtom-enabled" value="false" />
> 			<entry key="mtom-threshold" value="1024" />
> 		</jaxws:properties>
> 	</jaxws:client>
> </beans>
> 
-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com

Re: Convert Byte Array to Base64Binary

Posted by robbywillz <ro...@gmail.com>.
Hi,

Could any one please help me on the above post about the configuring the
cxf.xml....

-----
Regards,
William Rovinson
--
View this message in context: http://cxf.547215.n5.nabble.com/Convert-Byte-Array-to-Base64Binary-tp4696903p4727405.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Convert Byte Array to Base64Binary

Posted by robbywillz <ro...@gmail.com>.
Hi,

Thanks a lot for providing different ways to enabling or disabling the MTOM.
I could able to have a inline Base64Binary by disabling the MTOM and
increasing the MTOM threshold(1024).
I understood that MTOM will be enabled for attachment when threshold is
crossed, even through MTOM is disabled. Please correct me if i'm wrong.

Is there any way to configure through spring client configuration? I don't
want to make this changes in wsdl or in code as my code may run on Websphere
v6.1 with web services feature pack installed.

I've tried with following configuration and I named file as cxf.xml, it is
picked up by cxf but no effect on the configuration. It still converts to
XOP. Please help me?

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="
          http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans.xsd
          http://cxf.apache.org/jaxws 
          http://cxf.apache.org/schemas/jaxws.xsd">

	
	<jaxws:client id="ne3sRegistration"
		serviceClass="com.nsn.oss.ne3s.ws.gen.NE3SRegistrationPort"
address="/NE3SRegistrationService">
		<jaxws:properties>
			<entry key="mtom-enabled" value="false" />
			<entry key="mtom-threshold" value="1024" />
		</jaxws:properties>
	</jaxws:client>
</beans>



-----
Regards,
William Rovinson
--
View this message in context: http://cxf.547215.n5.nabble.com/Convert-Byte-Array-to-Base64Binary-tp4696903p4707011.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Convert Byte Array to Base64Binary

Posted by robbywillz <ro...@gmail.com>.
Hi Dan,

Thanks a lot for your response.
I'll surly try this.


-----
Regards,
William Rovinson
--
View this message in context: http://cxf.547215.n5.nabble.com/Convert-Byte-Array-to-Base64Binary-tp4696903p4703962.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Convert Byte Array to Base64Binary

Posted by Daniel Kulp <dk...@apache.org>.

Couple of options:

1) Turn off mtom.   That should keep it inlined.

2) Add @XmlInlineBinaryData  to the managerNonce field

3) Depending on how mtom is turned on, you can control the threshold size.   
For example, if using the @MTOM annotation, you can do
@MTOM(threshold=1024)
or similar to force MTOM for only larger byte[] sizes

Dan


On Saturday, August 13, 2011 12:17:51 PM robbywillz wrote:
> Hi,
> 
> I'm facing a problem in converting a Byte Array to Base64 Binary.
> The managerNonce supposed to be converted to Base64Binary format as it is
> defined as byte[], but it converts to XOP format. The server expects this in
> Base64Binary format.
> 
> Can you please help me on how to convert this to Base64 format?
> 
> I'm using Apache CXF 2.3.3 version.
> 
> --uuid:b151f053-b6cc-402f-a008-b1e2ca56dad1
> Content-Type: text/xml; charset=UTF-8; type="text/xml";
> Content-Transfer-Encoding: binary
> Content-ID: &lt;root.message@cxf.apache.org&gt;
> 
> <soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><startRegi
> stration
> xmlns="http://www.nokiasiemens.com/ne3s/1.0"><managerIdentity><uniqueId>wil
> liam_myne3s_test</uniqueId><type>ne3s_ws_client</type><vendor>NSN</vendor><r
> elease>1.0</release></managerIdentity><agentUniqueId>Esymac</agentUniqueId><
> notificationConsumerURL>http://localhost:7070/ne3sws/services</notificationC
> onsumerURL><reRegisterInterval>10</reRegisterInterval>*<managerNonce><xop:In
> clude xmlns:xop="http://www.w3.org/2004/08/xop/include"
> href="cid:0e2b6cc6-5048-4a46-b7c8-efb767126874-1@www.nokiasiemens.com"/></ma
> nagerNonce>*<soc>4a6fa268-957f-4061-9f30-a2b51c0e570f@apache.org</soc></star
> tRegistration></soap:Body></soap:Envelope>
> --uuid:b151f053-b6cc-402f-a008-b1e2ca56dad1
> Content-Type: application/octet-stream
> Content-Transfer-Encoding: binary
> Content-ID: <0e...@www.nokiasiemens.com>
> 
> 1313260562190
> 
> 
> Regards,
> William
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Convert-Byte-Array-to-Base64Binary-tp469690
> 3p4696903.html Sent from the cxf-user mailing list archive at Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com