<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Jitendra Kotamraju&apos;s Blog</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/" />
<modified>2008-10-06T21:16:47Z</modified>
<tagline></tagline>
<id>tag:weblogs.java.net,2008:/blog/jitu/300</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2008, jitu</copyright>
<entry>
<title>Metro GAP winners</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2008/10/metro_gap_winne.html" />
<modified>2008-10-06T21:16:47Z</modified>
<issued>2008-10-06T21:16:41Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jitu/300.10566</id>
<created>2008-10-06T21:16:41Z</created>
<summary type="text/plain">Congratulations to Metro GAP winners</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[<html><body>
Congratulations to <a href="http://wikis.sun.com/display/GAP/GAP+Winners">GAP winners</a>, specially to : Jungwook Chae, Tatu Saloranta, Ernesto Jose Perez Garcia, Karel Kolman, Franke Markus, Ryan de Laplante  who have contributed to GlassFish Metro web services and its sub projects. I also acknowledge that there are many others who contributed to metro community (you need to submit entries !). Thanks and congratulations to all.
<p>
There could be some other winners but I have a hard time mapping java.net ids to real names, so sorry if I missed you.
</body></html>]]>

</content>
</entry>
<entry>
<title>Control Over JAXBContext in JAX-WS RI/Metro</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2008/08/control_of_jaxb.html" />
<modified>2008-08-30T00:20:57Z</modified>
<issued>2008-08-30T00:20:46Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jitu/300.10368</id>
<created>2008-08-30T00:20:46Z</created>
<summary type="text/plain">An application can configure its own JAXBRIContext for an endpoint or a proxy and JAX-WS RI runtime uses that context for (un)marshalling, WSDL generation etc.</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[<html>
<title></title>
<body>
Finally, this RFE <a href="https://jax-ws.dev.java.net/issues/show_bug.cgi?id=282">Issue 282 : Control Over JAXBContext Creation</a> is resolved. This means an application can configure its own JAXBRIContext for an endpoint or a proxy and JAX-WS RI runtime uses that context for (un)marshalling, WSDL generation etc. It is implemented as a custom WebServiceFeature. See <a href="http://weblogs.java.net/blog/ramapulavarthi/archive/2007/01/extending_jaxws.html">Rama's blog on using custom feature</a>. Looks like, I cannot live without this extension. All the features like SchemaValidation, StreamingAttachment etc. are exposed using this extension.
<p>
Thanks to <a href="http://weblogs.java.net/blog/kohsuke/">Kohsuke</a> who created @UsesJAXBContext feature(after many reminders!! yeah, yeah he is busy with many other things like <a href="http://hudson.dev.java.net">hudson</a>, Brazil trip!!). Basically, this feature provides a JAXBRIContext that needs to be used in the runtime. Here is an endpoint sample that uses this feature:

<pre>
@WebService
<b>@UsesJAXBContext(ServerJAXBContextFactory.class)</b>
public class EchoImpl {
    ...
}

public class ServerJAXBContextFactory implements JAXBContextFactory {
    <b>public JAXBRIContext createJAXBContext(...) throws JAXBException {</b>
    ...
    }
}
</pre>

I added two test cases:
<a href="http://fisheye5.cenqua.com/browse/jax-ws-sources/jaxws-unit/testcases/fromjava/custom_client_jaxbcontext">custom_client_jaxbcontext</a>,
<a href="http://fisheye5.cenqua.com/browse/jax-ws-sources/jaxws-unit/testcases/fromjava/custom_server_jaxbcontext">custom_server_jaxbcontext</a>. Both these test cases create their own JAXBRIContext to do type substitution(but doesn't use @XmlSeeAlso). I think that it is also possible to influence (Un)Marshallers that are used by JAX-WS RI runtime using this feature.

Try the <a href="https://jax-ws.dev.java.net/servlets/ProjectDocumentList?folderID=6020&expandFolder=6020&folderID=6020">2.1.x nightly</a> and let us know your feedback. The feature will be part of JAX-WS RI 2.1.5/Metro 1.4.
</body>
</html>
]]>

</content>
</entry>
<entry>
<title>JAX-WS RI/Metro in IBM JDK 6</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2008/07/jaxws_rimetro_i_1.html" />
<modified>2008-07-31T22:11:28Z</modified>
<issued>2008-07-31T22:11:23Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jitu/300.10210</id>
<created>2008-07-31T22:11:23Z</created>
<summary type="text/plain">IBM&apos;s JDK 6 web services implementation is based on the JAX-WS RI/Metro web services implementation.</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[Earlier Kohsuke mentioned that <a href="http://weblogs.java.net/blog/kohsuke/archive/2006/08/even_ibm_chose.html">even IBM chose the JAXB RI for databinding</a>. But that was two years back and is not about the whole JAX-WS RI/Metro.

<p>
Looked at IBM's JDK in recent <a href="https://www14.software.ibm.com/iwm/web/cc/earlyprograms/websphere/wasndv7/index.shtml">WebSphere Application Server v7.0 (Open Beta)</a> release. This version is supposed to be based on Java EE 5 and Java SE 6. Since I am a JAX-WS RI/Metro guy, wanted to see what implementation it is using. So just tried wsimport:

<p>
<pre>
$ ./wsimport -version
JAX-WS RI IBM 2.1.1 in JDK 6
</pre>

<p>
There you go, it uses JAX-WS RI. It has pretty much the same web services bits(JAXB, SAAJ etc) as Sun's Java SE 6. But it uses different StAX impl, not SJSXP. Note that Metro bits are tested with <a href="http://woodstox.codehaus.org/">woodstox</a>, <a href="http://sjsxp.dev.java.net">sjsxp</a> parsers. Now it works with IBM's StAX impl.

<p>
As far as JAX-WS implementation goes, it has all the RI extensions like FastInfoset, AsyncProvider etc.

<p>
JAX-WS RI/Metro is part of many application servers, JDKs, frameworks etc. We must have done a good job :-)
</body>
</html>
]]>

</content>
</entry>
<entry>
<title>More transports for JAX-WS RI/Metro</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2008/07/more_transports_1.html" />
<modified>2008-07-28T19:15:59Z</modified>
<issued>2008-07-28T19:15:47Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jitu/300.10186</id>
<created>2008-07-28T19:15:47Z</created>
<summary type="text/plain">Some users are using dcom and WinInet transports with JAX-WS RI/Metro</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[<html>
<body>
Some more transports are being used with JAX-WS RI/Metro. 
<ul>
  <li>Forum user talks about creating a <a href="http://forums.java.net/jive/thread.jspa?messageID=280078">dcom</a> transport</li>
  <li>One more user pinged about creating WinInet transport</li>
</ul>

I started <a href="https://jax-ws-commons.dev.java.net/source/browse/jax-ws-commons/trunk/transport/grizzly-transport/">grizzly transport</a> for jax-ws endpoints, but it needs some more work especially on the deployment side. As always, I encourage you to host your extensions on <a href="http://jax-ws-commons.dev.java.net">jax-ws commons</a> project if you think that the extensions benefit metro community.
</body>
</html>
]]>

</content>
</entry>
<entry>
<title>JAX-WS RI 2.1.4 Released</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2008/05/jaxws_ri_214_re.html" />
<modified>2008-05-14T00:19:19Z</modified>
<issued>2008-05-14T00:19:11Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jitu/300.9798</id>
<created>2008-05-14T00:19:11Z</created>
<summary type="text/plain">JAX-WS RI team is pleased to announce the release of 2.1.4 version. It is also included in Metro 1.2</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[<html>
<title>JAX-WS RI 2.1.4 Released</title>
<body>
JAX-WS RI team is pleased to announce the release of <a href="https://jax-ws.dev.java.net/2.1.4/">2.1.4</a> version. It is also included in <a href="https://metro.dev.java.net/1.2/">Metro 1.2</a>
<p>

It has two features:
<ul>
<li><a href="http://weblogs.java.net/blog/jitu/archive/2008/03/alternative_to_1.html">Simplified "Starting from Java" development model</a></li>
<li>See dual_binding sample to enable a same service for XML/HTTP and SOAP/HTTP. We need to do some more work in this area.</li>
</ul>

<p>
Lot of bug fixes:
<ul>
<li><a href="https://jax-ws.dev.java.net/issues/buglist.cgi?Submit+query=Submit+query&issue_type=DEFECT&issue_type=ENHANCEMENT&component=jax-ws&issue_status=RESOLVED&issue_status=VERIFIED&resolution=FIXED&target_milestone=2.1.4&email1=&emailtype1=exact&emailassigned_to1=1&email2=&emailtype2=exact&emailreporter2=1&issueidtype=include&issue_id=&changedin=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&short_desc=&short_desc_type=fulltext&long_desc=&long_desc_type=fulltext&issue_file_loc=&issue_file_loc_type=fulltext&status_whiteboard=&status_whiteboard_type=fulltext&keywords=&keywords_type=anytokens&field0-0-0=noop&type0-0-0=noop&value0-0-0=&cmdtype=doit&namedcmd=as91only&newqueryname=&order=Reuse+same+sort+as+last+time">2.1.4 bug fixes</a></li>
</ul>

<p>

The bits are also pushed to the <a href="http://download.java.net/maven/1/com.sun.xml.ws/">JAX-WS Maven repository</a>.

<p>
Metro 1.2 has woodstox as the default StAX parser. If you are using MTOM, you will run into this <a href="https://jax-ws.dev.java.net/issues/show_bug.cgi?id=558">bug</a>. The workaround is to put sjsxp.jar first in the classpath or use system properties to enable sjsxp StAX parser.

<p>
Continue sending your feedback to the <a href="http://forums.java.net/jive/forum.jspa?forumID=46">forum</a> and to the <a href="mailto:users@metro.dev.java.net">mailing list</a>.

</body>
</html>
]]>

</content>
</entry>
<entry>
<title>JAX-WS RI &amp; DIME</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2008/03/jaxws_ri_dime.html" />
<modified>2008-03-06T03:06:20Z</modified>
<issued>2008-03-06T03:06:13Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jitu/300.9319</id>
<created>2008-03-06T03:06:13Z</created>
<summary type="text/plain">Oliver Treichel wrote a DIME extension for JAX-WS RI and hosted it on JAX-WS commons.</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[<html>
<title>JAX-WS RI & DIME</title>
<body>
Oliver Treichel wrote a DIME extension for JAX-WS RI and hosted it on <a href="https://jax-ws-commons.dev.java.net/dime/">JAX-WS commons</a>. His usecase is to interoperate with MS Soap Toolkit 3.0 and it supports only DIME(not MTOM). Once again, it shows JAX-WS RI is built for extensibility. Thanks to Oliver for hosting this on <a href="https://jax-ws-commons.dev.java.net">JAX-WS Commons</a> so that the other users also benefit from this.

</body>
</html>
]]>

</content>
</entry>
<entry>
<title>Alternative to JAX-WS RI&apos;s wsgen</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2008/03/alternative_to_1.html" />
<modified>2008-03-04T02:00:55Z</modified>
<issued>2008-03-03T23:13:28Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jitu/300.9308</id>
<created>2008-03-03T23:13:28Z</created>
<summary type="text/plain">For services starting from java, wsgen need not be run anymore. JAX-WS RI 2.1.4 dynamically generates wrapper and exception beans.</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[<html>
<title>Wrapper Beans</title>
<body>

See a simple doc/lit wrapper style web service starting from java.

<pre>
package pkg;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.xml.ws.Endpoint;

@WebService
public class AddService {
    @WebMethod(exclude=true)
    public static void main(String ... args) throws Exception {
        Endpoint.publish("http://localhost:8181/add", new AddService());
        ...
    }

    public int add(int num1, int num2) {
        return num1+num2;
    }
}

$ javac pkg/AddService.java
$ wsgen.sh -d gen -keep -cp . pkg.AddService
$ ls gen/pkg/jaxws
Add.class AddResponse.class
</pre>

Here Add.class and AddResponse.class are request and response wrapper bean classes respectively.
<p>

So far with JAX-WS RI, you need to run wsgen for doc/lit wrapper case or when service throws any checked exceptions. wsgen generates request/response wrapper bean classes and exception bean classes. JAX-WS spec clearly defined rules to create these portable classes, so that the same application works on different JAX-WS implementations. But all the required information to generate these classes can be got from the SEI, so an implementation may generate these classes on the fly. From JAX-WS RI 2.1.4 onwards, you don't have to run wsgen, the runtime takes care of it by generating these classes dynamically. That's right, you don't have to run "wsgen" ! See the sample logging output, when there are no wrapper classes in the classpath:

<pre>
$ javac pkg/AddService.java
$java pkg.AddService

INFO: Dynamically creating request wrapper Class pkg.jaxws.Add
Mar 3, 2008 1:58:30 PM com.sun.xml.ws.model.WrapperBeanGenerator createBeanImage
INFO: 
@XmlRootElement(name=add, namespace=http://pkg/)
@XmlType(name=add, namespace=http://pkg/, propOrder={arg0, arg1})
public class pkg.jaxws.Add {

    @XmlRootElement(name=arg0, namespace=)
    public I arg0

    @XmlRootElement(name=arg1, namespace=)
    public I arg1

}

INFO: Dynamically creating response wrapper bean Class pkg.jaxws.AddResponse
Mar 3, 2008 1:58:30 PM com.sun.xml.ws.model.WrapperBeanGenerator createBeanImage
INFO: 
@XmlRootElement(name=addResponse, namespace=http://pkg/)
@XmlType(name=addResponse, namespace=http://pkg/)
public class pkg.jaxws.AddResponse {

    @XmlRootElement(name=return, namespace=)
    public I _return

}
</pre>
<p>
I would say starting from java, building services have never been so easy :-) Let me know your feedback, you need to try the <a href="https://jax-ws.dev.java.net/servlets/ProjectDocumentList?folderID=6020">2.1.x nightlies</a> for this feature.
</body>
</html>]]>

</content>
</entry>
<entry>
<title>Introducing mimepull - Streaming API for MIME messages</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2007/10/introducing_mim.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-10-12T23:54:41Z</issued>
<id>tag:weblogs.java.net,2007:/blog/jitu/300.8424</id>
<created>2007-10-12T23:54:41Z</created>
<summary type="text/plain"><![CDATA[ New project mimepull allows applications to access MIME attachments in a streaming fashion.&nbsp; Often times,&nbsp; larger MIME messages cannot be loaded into memory. Hence the whole message or attachment parts are written to a file system and access to...]]></summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[<html>
<body>
New project <a href="http://mimepull.dev.java.net">mimepull</a>
allows applications to access MIME attachments in a streaming
fashion.&nbsp; Often times,&nbsp; larger MIME messages cannot
be loaded
into
memory. Hence the whole message or attachment parts are written to a
file system and access to the attachment parts is provided using those
files.
<p>But in some cases, the MIME attachment parts can be accessed
by
applications in a streaming fashion, provided:</p>
<ul>
  <li>The parts are accessed
orderly(as they appear in the stream)</li>
  <li>The parts are accessed only
once.</li>
</ul>
<p>In such situations, the parts need not be written to file
system(however large message it is !). How is it implemented
?&nbsp;MIME
message parsing is done using pull-parsing, much similar to <a
 href="http://www.jcp.org/en/jsr/detail?id=173"><tt>StAX</tt></a>
in XML world. Using the parser one can pull chunk after chunk of the
MIME message.&nbsp;</p>
<pre>for e.g.:<br>public void parse() {<br>    MIMEParser parser = new MIMEParser(InputStream, boundary, ...);<br>    Iterator&lt;MIMEEvent&gt; it = parser.iterator();<br>    while(it.hasNext()) {<br>        MIMEEvent event = it.next();<br>        switch(event.getEventType()) {<br>            case START_MESSAGE :<br>            case START_PART :<br>            case HEADERS :<br>            case CONTENT :	// called multiple times for a attachment<br>            case END_PART :<br>            case END_MESSAGE :<br>       }<br>    }<br> }<br></pre>
<p>But an application developer doesn't have to worry about this
low-level parsing details. There is a nice high-level API to get
different attachment parts in a streaming fashion.&nbsp;The
MIMEParts are constructed lazily, and parsing is
triggered by applications while reading the attachment parts.
MIMEConfig provides various configuration options to control parsing
and storing MIME parts. It is also possible to read MIME parts in any
order and multiple times, but doing so may create attachment parts on
the file system.</p>
<pre>// Parts are accessed in order. The data is accessed in a streaming fashion<br>// using readOnce() and data is not stored in temp files.<br>public void parse() {<br>    InputStream in = ...<br>    String boundary = ...<br>    MIMEConfig config = ...<br>    MIMEMessage mm = new MIMEMessage(in, boundary, config);<br><br>    MIMEPart partA = mm.getPart("partA");<br>    InputStream ais = partA.readOnce();<br>    // read ais<br><br>    MIMEPart partB = mm.getPart("partB");<br>    InputStream bis = partB.readOnce();<br>    // read bis<br><br>}&nbsp;</pre>
<p>The implementation would be easier if the parts are accessed
in an order. Since parts can be accessed in any order, it required more
careful approach. &nbsp;Also while the first part's stream is read
half way, the application could access the second part. We wanted to
have an efficient implementation and avoid writing to file system
whereever we can(some situations, we cannot avoid writing those large
MIME parts to temp files). Thanks to <a
 href="http://weblogs.java.net/blog/kohsuke/">Kohsuke</a>
who helped me in implementing this in an efficient way.</p>
<p>In a future blog, I would write how mimepull is used in JAX-WS
RI 2.1.3 and JAX-WS RI applications take advantage of this to
send/receive larger attachments.</p>
</body>
</html>
]]>

</content>
</entry>
<entry>
<title>No SAAJ RI dependency in JAX-WS RI</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2007/09/no_saaj_ri_depe_1.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-09-21T03:39:22Z</issued>
<id>tag:weblogs.java.net,2007:/blog/jitu/300.8292</id>
<created>2007-09-21T03:39:22Z</created>
<summary type="text/plain">Issue : 54 wants JAX-WS RI to be independent of Sun&apos;s StAX impl (sjsxp) and SAAJ impl(SAAJ RI). The dependency on SJSXP is removed long time back. It works well with woodstox StAX parser. The dependency on SAAJ RI is...</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[<a href="https://jax-ws.dev.java.net/issues/show_bug.cgi?id=54">Issue : 54</a> wants JAX-WS RI to be independent of Sun's StAX impl (<a href="http://sjsxp.dev.java.net">sjsxp</a>) and SAAJ impl(<a href="http://saaj.dev.java.net">SAAJ RI</a>). The dependency on SJSXP is removed long time back. It works well with <a href="http://woodstox.codehaus.org/">woodstox</a> StAX parser. The dependency on SAAJ RI is removed in 2.1.3. This would help vendors to package JAX-WS RI with their SAAJ implementations. During this process, I had to pull in SAAJ RI's DataContentHandler implementations, Content-Type MIME header parsing classes to JAX-WS RI.

<br><br>
This is interesting. Intially, SAAJ RI pulled-in MIME processing classes from JavaMail and removed its dependency on JavaMail. Now JAX-WS RI did the same with SAAJ RI and couple of JavaMail classes finally landed into JAX-WS RI !! 

<br><br>
If MIME processing is a separate project, it would be helpful to many projects.  But JAX-WS RI require code only for parsing MIME messages not so much of creating/editing MIME messages. Even in parsing, it requires only parsing Content-Type header. Similarly, if URI escaping and encoding is a separate utility class in Java SE(unfortunately, it's implementation is hidden in java.net.URI), it would be useful to many projects. Though assembling many small pieces of reusable software is hard, but we require them. Otherwise, they will be duplicated.]]>

</content>
</entry>
<entry>
<title>JAX-WS RI and Compression</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2007/07/jaxws_ri_and_co_1.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-07-06T22:50:00Z</issued>
<id>tag:weblogs.java.net,2007:/blog/jitu/300.7805</id>
<created>2007-07-06T22:50:00Z</created>
<summary type="text/plain"> JAX-WS RI provides way to send/receive compressed messages on the client side. On the server side, many of the servlet containers like Glassfish, Tomcat provide support for compression. JAX-WS applications can take advantage of this to save bandwidth. First,...</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[<html>
<body>

<A href="http://jax-ws.dev.java.net">JAX-WS RI</A> provides way to send/receive compressed messages on the client side. On the server side, many of the servlet containers like Glassfish, Tomcat provide support for compression. JAX-WS applications can take advantage of this to save bandwidth. First, let us see how we can configure the servlet containers. 

<p>

See Tomcat <A href="http://tomcat.apache.org/tomcat-5.5-doc/config/http.html"> documentation</A> on how to configure compression. I configured Tomcat as follows:

<pre class="xml">
  &lt;Connector port="8080" 
    ...
    compression="on"
    compressionMinSize="20"
    compressableMimeType="text/xml"
  />
</pre>

<p>

Similarly, see  <A href="http://weblogs.java.net/blog/jfarcand/archive/2006/06/enabling_http_c_1.html">JeanFrancois's blog</A> on how to configure <A href="http://glassfish.dev.java.net">GlassFish</a> for compression. I configured GlassFish domain as follows:

<pre class="xml">
  &lt;http-listener port="8080" ...  >
    ...
    &lt;property name="compression" value="on"/>
    &lt;property name="compressionMinSize" value="20"/>
    &lt;property name="compressableMimeType" value="text/xml"/>
  &lt;/http-listener>
</pre>


Now, let us see how we can configure JAX-WS clients to use compression. The client sends Accept-Encoding HTTP header to indicate its capabilities to process compressed data. If the server sends compressed data (contains Content-Encoding HTTP header), JAX-WS RI client runtime automatically uncompresses the response data. The wire traffic would like like this:

<pre>
---[HTTP request]---
<b>Accept-Encoding: gzip</b>
SOAPAction: "urn:test:hello"
Content-Type: text/xml;charset="utf-8"
Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
&lt;S:Envelope ... &lt;/S:Envelope>
---[HTTP response 200]---
Date: Tue, 03 Jul 2007 19:04:19 GMT
<b>Content-encoding: gzip</b>
Content-type: text/xml;charset=utf-8
null: HTTP/1.1 200 OK
Transfer-encoding: chunked
Server: Apache-Coyote/1.1
Vary: Accept-Encoding
[GZIP Compressed SOAP Envelope]
</pre>

<p>

The way to add Accept-Encoding HTTP header is as follows:

<pre class="java">
stub = ...
Map&lt;String, List&lt;String>> httpHeaders = new HashMap&lt;String, List&lt;String>>();
httpHeaders.put("Accept-Encoding", Collections.singletonList("gzip"));
Map&lt;String, Object> ctxt = ((BindingProvider)stub).getRequestContext();
ctxt.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);
</pre>

JAX-WS RI client can also send requests with compression, but currently Tomcat and GlassFish do not uncompress the requests. Also JAX-WS server runtime doesn't uncompress these requests(does anybody need it ?). So it is useful only when a server can process these requests. Anyway, the way you do this with RI is:

<pre class="java">
httpHeaders.put("Content-Encoding", Collections.singletonList("gzip"));
</pre>

This tip is also captured in <A href="https://jax-ws.dev.java.net/guide/HTTP_headers.html#Enabling_HTTP_compression_on_the_client">JAX-WS RI User Guide</A>.

</body>
</html>
]]>

</content>
</entry>
<entry>
<title>SMTP transport extension for JAX-WS RI</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2007/05/smtp_transport.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-05-07T04:05:30Z</issued>
<id>tag:weblogs.java.net,2007:/blog/jitu/300.7252</id>
<created>2007-05-07T04:05:30Z</created>
<summary type="text/plain"> jax-ws-commons: JAX-WS commons - SMTP transport for JAX-WS Finally, we (vivek, kohsuke and I) put together a SMTP transport for JAX-WS !! JAX-WS works with various transports and it also provides plugin extensions to write any custom transport. SMTP...</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>jax-ws-commons: JAX-WS commons - SMTP transport for
JAX-WS
  </title>
</head>
<body class="composite">
<div id="bodyColumn">
<div id="contentBox">
<div class="section">
<p>Finally, we (<a href="http://weblogs.java.net/blog/vivekp/">vivek</a>,
<a href="http://weblogs.java.net/blog/kohsuke">kohsuke</a>
and I) put together a SMTP transport for JAX-WS !! JAX-WS works with
various transports and it also provides plugin
extensions to write any custom transport. SMTP transport takes
advantage of these extensions. SMTP transport is implemented as a custom
transport using <a
 href="http://fisheye5.cenqua.com/browse/jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/api/server/Adapter.java?r=1.2">Adapter</a>
extension on the server side and <a
 href="http://fisheye5.cenqua.com/browse/jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/api/pipe/TransportTubeFactory.java?r=1.2">TransportTubeFactory.java</a>
on the client side.</p>
<h2>Basics</h2>
For the communication to happen between "Me" and "You", there needs to
be two inboxes: "My Inbox" and "Your Inbox".&nbsp; "Me" sends
request messages to "You" and expect responses in "My Inbox".
Similarly,&nbsp; "You" sends response messages to "My Inbox" in
order to reach "Me".<br>
<p><a href="http://weblogs.java.net/blog/jitu/archive/smtp.png"><img
 style="border: 0px solid ; width: 691px; height: 255px;" alt=""
 src="http://weblogs.java.net/blog/jitu/archive/smtp.png"></a></p>
<h2>SMTP advantages</h2>
<ul>
  <li>It is reachable. No server setup is necessary.</li>
  <li>Great asynchrony. Server need not&nbsp;be there when
client sends a request message.</li>
</ul>
</div>
<div class="section">
<h2>Client-side Programming</h2>
<p>You need <tt>jaxws-smtp.jar</tt> and JavaMail in
your classpath for this to work. Typical client code would like this:</p>
<div class="source">
<pre>public void testSmtp() {<br>    SMTPTransportTube.dump = true; // Enable logging<br><br>    SMTPFeature feature = new SMTPFeature("smtp.host", "me@sun.com");<br>    feature.setPOP3("pop.host", "uid", "password");<br>    GreetingService proxy =<br>        new GreetingServiceService().getGreetingServicePort(feature);<br><br>    WSBindingProvider bp = (WSBindingProvider)bp;<br>    bp.setAddress("smtp://you@sun.com");<br>    ... = proxy.sayHelloTo("...");<br>    bp.close();<br>}<br></pre>
</div>
<p>This
configures SMTPFeature with SMTP(sending) and POP3(receiving)
configuration. This feature is used to create proxy. Once the endpoint
address is set, then proxy can be used to invoke web service.</p>
</div>
<div class="section">
<h2>Server-side Configuration</h2>
<p>JAX-WS SMTP extension can be used with <a
 href="https://jax-ws-commons.dev.java.net/spring/">JAX-WS
Spring extension</a> for more flexible configuration --- in
particular to expose the same endpoint as both HTTP and SMTP. See <a
 href="https://jax-ws-commons.dev.java.net/source/browse/jax-ws-commons/trunk/transport/smtp/test-app/">the
sample application</a> for the complete example of how to put
this all together by using Maven.</p>
<div class="source">
<pre>&lt;beans<br>  xmlns:ws ="http://jax-ws.dev.java.net/spring/core"<br>  xmlns:wsm="http://jax-ws.dev.java.net/spring/smtp"<br>  xsi:schemaLocation=<br>    "http://jax-ws.dev.java.net/spring/smtp http://jax-ws.dev.java.net/spring/smtp.xsd<br>     http://jax-ws.dev.java.net/spring/core http://jax-ws.dev.java.net/spring/core.xsd"&gt;<br><br>  &lt;wsm:smtp service="#myservice" incoming="#in" outgoing="#out" /&gt;<br>  &lt;wsm:pop3 id="in" host="pop3.Host" uid="uid" password="password" /&gt;<br>  &lt;wsm:sender id="out" host="smtp.host" from="server.from@com"/&gt;<br><br>  &lt;ws:service id="myservice"&gt;<br>    &lt;ws:bean&gt;<br>      &lt;bean class="greeter.GreetingService" /&gt;<br>    &lt;/ws:bean&gt;<br>  &lt;/ws:service&gt;<br><br>&lt;/beans&gt;<br></pre>
</div>
<p>Alternatively, you can also configure the srever side
programatically without Spring like <a
 href="https://jax-ws-commons.dev.java.net/source/browse/jax-ws-commons/trunk/transport/smtp/jaxws-smtp/src/test/java/pop3/SmtpTest.java?view=markup">this</a>.</p>
<h2>Testing</h2>
<ul>
  <li>We automated the testing using <a
 href="https://mock-javamail.dev.java.net/">mock javamail</a>
project.</li>
</ul>
<p>We'll be showing a SMTP demo&nbsp; (along with JSON demo!)
in our JavaOne session <a
 href="http://www28.cplan.com/cc158/sessions_catalog.jsp?ilc=158-1&amp;ilg=english&amp;isort=&amp;isort_type=&amp;is=yes&amp;icriteria1=+&amp;icriteria2=+&amp;icriteria7=+&amp;icriteria9=TS-4948&amp;icriteria8=&amp;icriteria3=">TS-4948
"Unleashing the Power of JAX-WS RI: Spring, Stateful Web Services,
SMTP, and More"</a>, so mark your calendars accordingly ...</p>
</div>
</div>
</div>
<div class="xright"></div>
<br>
<br>
<br>
<br>
<br>
<div id="footer">
<p><a href="http://today.java.net/pub/q/java_net_rss"><br>
</a>&nbsp;<b></b></p>
<br>
</div>
</body>
</html>
]]>

</content>
</entry>
<entry>
<title>JAX-WS RI and woodstox</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2007/04/woodstox_and_ja.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-04-20T02:20:13Z</issued>
<id>tag:weblogs.java.net,2007:/blog/jitu/300.7103</id>
<created>2007-04-20T02:20:13Z</created>
<summary type="text/plain">JAX-WS RI 2.1.1 RC1 should work with any StAX implementation. I tried many jax-ws tests with woodstox 3.2.1 version and all of them are passing. Let us know if you face any problems with your application. All you need to...</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[<a href="https://jax-ws.dev.java.net/2.1.1rc1/">JAX-WS RI 2.1.1 RC1</a> should work with any StAX implementation. I tried many jax-ws tests with <a href="http://woodstox.codehaus.org/">woodstox 3.2.1</a> version and all of them are passing. Let us know if you face any problems with your application. All you need to do is replace sjsxp.jar with woodstox jar.]]>

</content>
</entry>
<entry>
<title>Google&apos;s AdSense and JAX-WS</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2007/04/googles_adsense_1.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-04-12T19:19:09Z</issued>
<id>tag:weblogs.java.net,2007:/blog/jitu/300.7040</id>
<created>2007-04-12T19:19:09Z</created>
<summary type="text/plain">I came across Google&apos;s AdSense API Developer&apos;s Guide. Disappointed to see that there is no JAX-WS sample client code. So I looked at the Axis client, thought JAX-WS client code would look the same. Indeed, it was the case. First...</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[I came across Google's <a href="http://code.google.com/apis/adsense/developer/adsense_api_samples.html">AdSense API Developer's Guide</a>. Disappointed to see that there is no <a href="http://jax-ws.dev.java.net">JAX-WS</a> sample client code. So I looked at the <a href="http://code.google.com/apis/adsense/developer/samples/java/CreateAccount.java.txt">Axis client</a>, thought JAX-WS client code would look the same. Indeed, it was the case.

First need to create a proxy code. Used JAX-WS's <a href="https://jax-ws.dev.java.net/nonav/2.1/docs/wsimport.html">wsimport</a> to create proxy code. The generated code is completely portable and much smaller. Here is the command:
<pre>
wsimport -p com.google.api.adsense.v2 -d gen https://www.google.com/api/adsense/v2/AccountService?wsdl
</pre>

This <a href="https://www.google.com/api/adsense/v2/AccountService?wsdl">WSDL</a> defines additional headers in soap:binding section. soap:binding changing the porttype by adding additional headers is not a good idea. JAX-WS doesn't
capture these in the SEI. The portable way to add these headers to the messages is using SOAP handlers. Using SOAP handlers is a bit complex, but we can add these headers easily using RI's extension. This is similar to what Axis is doing in the <a href="http://code.google.com/apis/adsense/developer/samples/java/CreateAccount.java.txt">axis sample code</a>. But in our code, we could use JAXB !.

<pre>
ObjectFactory fact = new ObjectFactory();
((WSBindingProvider)accountService).setOutboundHeaders(
    fact.createDeveloperEmail(developerEmail),
    fact.createDeveloperPassword(developerPassword),
    fact.createClientId("ignored"));
</pre>

The other difference is some types are mapped to List. One can get arrays also
by passing customization files to wsimport.

Here is the complete <a href="http://weblogs.java.net/blog/jitu/archive/JaxwsCreateAccount.java">sample code using JAX-WS</a>
]]>

</content>
</entry>
<entry>
<title>JAX-WS RI in BEA WebLogic Server 10</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2007/04/jaxws_ri_in_bea.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-04-04T21:20:29Z</issued>
<id>tag:weblogs.java.net,2007:/blog/jitu/300.6991</id>
<created>2007-04-04T21:20:29Z</created>
<summary type="text/plain">BEA WebLogic Server 10 becomes one more vendor implementation for Java EE 5. Product Overview says &quot;New core Web services technologies have been implemented including the Java API for XML Web Services (JAX-WS 2.0) and Java API for XML Binding...</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[BEA WebLogic Server 10 becomes one more vendor implementation for Java EE 5.

<A href="http://www.bea.com/framework.jsp?CNT=overview.htm&FP=/content/products/weblogic/server/">Product Overview</A> says

<p>
"New core Web services technologies have been implemented including the Java API for XML Web Services (JAX-WS 2.0) and Java API for XML Binding (JAXB 2.0). BEA implements JAX-WS 2.0 based on the GlassFish community project (another blended example), which provides a solid implementation supported by the Java community."

<p>
<A href="http://jax-ws.dev.java.net">JAX-WS RI</A> is going places. Many application servers, tool kits and frameworks are including RI's implementation of JAX-WS 2.0 based on its quality, performance and extensibility. I wonder what all <A href="http://fisheye5.cenqua.com/browse/jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/api/pipe/Pipe.java?r=mr-21">Pipe</A>/<A href="http://fisheye5.cenqua.com/browse/jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/api/pipe/Tube.java?r=mr-21">Tube</A>s are there in WebLogic to provide more functionality.]]>

</content>
</entry>
<entry>
<title>Thread Scoped JAX-WS endpoint instances</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jitu/archive/2007/02/thread_scoped_j.html" />
<modified>2008-06-24T19:17:03Z</modified>
<issued>2007-02-10T01:44:35Z</issued>
<id>tag:weblogs.java.net,2007:/blog/jitu/300.6523</id>
<created>2007-02-10T01:44:35Z</created>
<summary type="text/plain">This is similar to the other extension HttpSessionScope. Traditionally JAX-WS has never taken advantage of object state, just like servlet. That is, the container creates only one instance of your service class, and then have it serve all the requests...</summary>
<author>
<name>jitu</name>

<email>Jitendra.Kotamraju@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jitu/">
<![CDATA[<p>This is similar to the other extension <a href="https://jax-ws-commons.dev.java.net/nonav/http-session-scope/"><tt>HttpSessionScope</tt></a>. Traditionally JAX-WS has never taken advantage of object state, just like servlet. That is, the container creates only one instance of your service class, and then have it serve all the requests concurrently. This makes it impossible to set values to instance fields, as you'll experience concurrency problem as soon as multiple threads hit your service.</p><p>Say you have a service, and its web methods try to access Database using Connection object. Connection object doesn't handle concurrent accesses, hence the access needs to be synchronized. For e.g.:</p><div class="source"><pre>@WebService
public class DataService {
    Connection con;

    public synchronized void delete() {
        Statement stmt = con.createStatement();
        stmt.executeQuery();
    }

    public synchronized void add() {
        Statement stmt = con.createStatement();
        stmt.executeQuery();
    }
}</pre></div><p>This will have performance issues since some of the requests need to wait until a current request is finished. To avoid synchronization, one could create Connection objects in each invocation and that is even more expensive! So we need exclusive access to Connection object and reuse them exclusively for other invocations. This can be achieved by creating more instances and using an instance exclusively for one invocation. To achive this, jax-ws runtime creates instances and stores and reuses them from ThreadLocal.</p><div class="source"><pre>import org.jvnet.jax_ws_commons.thread_scope.ThreadScope;

@WebService
@ThreadScope
public class DataService {
    Connection con;

    public void delete() {
        Statement stmt = con.createStatement();
        stmt.executeQuery();
    }

    public void add() {
        Statement stmt = con.createStatement();
        stmt.executeQuery();
    }
}</pre></div><p>The <tt>@ThreadScope</tt> annotation tells the JAX-WS RI to create one instance of <tt>DataService</tt> per each thread. No need to have synchronized keyword.</p>

You can download the extension <a href="https://jax-ws-commons.dev.java.net/nonav/thread-scope/">here</a>]]>

</content>
</entry>

</feed>