dev@jax-ws.java.net

Re: CVS update [rearch-2005]: /jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/client/, /jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/api/message/, /jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/developer/

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 04 Apr 2006 10:07:56 -0700

I wonder if there's any way to make this work without defining a FI
specific property on a Packet like this.

Wouldn't it better for the FI encoder or transport to keep information?
The content negotiation is a property of the endpoint, not that of a
packet, right?

sandoz_at_dev.java.net wrote:
> Tag: rearch-2005
> User: sandoz
> Date: 2006/04/04 08:15:03
>
> Modified:
> jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/client/RequestContext.java
> jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/client/BindingProviderProperties.java
> jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/client/ContentNegotiation.java
> jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/api/message/Packet.java
> jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/developer/JAXWSProperties.java
>
> Log:
> Added content negotiation property to the request context and the packet.
>
> File Changes:
>
> Directory: /jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/client/
> =================================================================
>
> File [changed]: RequestContext.java
> Url: https://jax-ws-sources.dev.java.net/source/browse/jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/client/RequestContext.java?r1=1.5.10.5&r2=1.5.10.6
> Delta lines: +20 -0
> --------------------
> --- RequestContext.java 16 Feb 2006 22:37:12 -0000 1.5.10.5
> +++ RequestContext.java 4 Apr 2006 15:14:57 -0000 1.5.10.6
> @@ -129,6 +129,26 @@
> }
>
> /**
> + * The value of {_at_link ContentNegotiation#PROPERTY}
> + * property.
> + */
> + public ContentNegotiation contentNegotiation = ContentNegotiation.none;
> +
> + @Property(ContentNegotiation.PROPERTY)
> + public String getContentNegotiationString() {
> + return contentNegotiation.toString();
> + }
> +
> + public void setContentNegotiationString(String s) {
> + if(s==null)
> + contentNegotiation = ContentNegotiation.none;
> + else {
> + // TODO should IllegalArgumentException be caught here?
> + contentNegotiation = ContentNegotiation.valueOf(s);
> + }
> + }
> +
> + /**
> * {_at_link Map} exposed to the user application.
> */
> private final MapView mapView = new MapView();
>
> File [changed]: BindingProviderProperties.java
> Url: https://jax-ws-sources.dev.java.net/source/browse/jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/client/BindingProviderProperties.java?r1=1.11.8.1&r2=1.11.8.2
> Delta lines: +56 -12
> ---------------------
> --- BindingProviderProperties.java 27 Jan 2006 20:22:11 -0000 1.11.8.1
> +++ BindingProviderProperties.java 4 Apr 2006 15:14:58 -0000 1.11.8.2
> @@ -76,51 +76,95 @@
> public static final String XML_ENCODING_VALUE = "xml.encoding"; // deprecated
> public static final String ACCEPT_ENCODING_PROPERTY = "accept.encoding";
>
> + /**
> + * HTTP Content-Type headser field.
> + */
> public static final String CONTENT_TYPE_PROPERTY = "Content-Type";
> +
> + /**
> + * HTTP Content-Type entity-header field.
> + */
> public static final String SOAP_ACTION_PROPERTY = "SOAPAction";
> + /**
> + * HTTP SOAPAction request-header field.
> + */
> public static final String ACCEPT_PROPERTY = "Accept";
>
> - // FI + SOAP 1.1
> + /**
> + * MIME type for a SOAP 1.1 Infoset encoded as a fast infoset document.
> + */
> public static final String FAST_INFOSET_TYPE_SOAP11 =
> "application/fastinfoset";
>
> - // FI + SOAP 1.2
> + /**
> + * MIME type for a SOAP 1.2 Infoset encoded as a fast infoset document.
> + */
> public static final String FAST_INFOSET_TYPE_SOAP12 =
> "application/soap+fastinfoset";
>
> - // XML + XOP + SOAP 1.1
> + /**
> + * MIME type for a XML Infoset encoded as a fast infoset document.
> + */
> + public static final String FAST_INFOSET_CONTENT_TYPE_VALUE =
> + "application/fastinfoset";
> +
> + /**
> + * MIME type for a SOAP 1.1 Infoset transformed using XOP and encoded as an
> + * XML document as a part of a XOP MIME package.
> + */
> public static final String XOP_SOAP11_XML_TYPE_VALUE =
> "application/xop+xml;type=\"text/xml\"";
>
> - // XML + XOP + SOAP 1.2
> + /**
> + * MIME type for a SOAP 1.2 Infoset transformed using XOP and encoded as an
> + * XML document as a part of a XOP MIME package.
> + */
> public static final String XOP_SOAP12_XML_TYPE_VALUE =
> "application/xop+xml;type=\"application/soap+xml\"";
>
> + /**
> + * MIME type for a XML Infoset encoded as an XML document.
> + */
> public static final String XML_CONTENT_TYPE_VALUE = "text/xml";
>
> + /**
> + * MIME type for a SOAP 1.2 Infoset encoded as an XML document.
> + */
> public static final String SOAP12_XML_CONTENT_TYPE_VALUE = "application/soap+xml";
>
> + /**
> + * Base HTTP Accept request-header.
> + */
> public static final String STANDARD_ACCEPT_VALUE =
> "application/xop+xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2";
>
> + /**
> + * HTTP Accept request-header for SOAP 1.2 infosets encoded as XML documents.
> + */
> public static final String SOAP12_XML_ACCEPT_VALUE =
> "application/soap+xml" + ", " + STANDARD_ACCEPT_VALUE;
>
> + /**
> + * HTTP Accept request-header for SOAP 1.1 infosets encoded as XML documents.
> + */
> public static final String XML_ACCEPT_VALUE =
> XML_CONTENT_TYPE_VALUE + ", " + STANDARD_ACCEPT_VALUE;
>
> - public static final String XML_FI_ACCEPT_VALUE =
> - FAST_INFOSET_TYPE_SOAP11 + ", " + XML_ACCEPT_VALUE;
> -
> + /**
> + * HTTP Accept request-header for SOAP 1.2 infosets encoded as fast infoset
> + * documents, includes SOAP 1.2 infosets encoded as XML documents.
> + */
> public static final String SOAP12_XML_FI_ACCEPT_VALUE =
> FAST_INFOSET_TYPE_SOAP12 + ", " + SOAP12_XML_ACCEPT_VALUE;
>
> + /**
> + * HTTP Accept request-header for SOAP 1.1 infosets encoded as fast infoset
> + * documents, includes SOAP 1.1 infosets encoded as XML documents.
> + */
> + public static final String XML_FI_ACCEPT_VALUE =
> + FAST_INFOSET_TYPE_SOAP11 + ", " + XML_ACCEPT_VALUE;
> +
> public String DISPATCH_CONTEXT = "com.sun.xml.ws.client.dispatch.context";
>
> public static final String BINDING_ID_PROPERTY = "com.sun.xml.ws.binding";
> -
> -// // Content negotiation property: values "none", "pessimistic" and "optimistic"
> -// public static final String CONTENT_NEGOTIATION_PROPERTY =
> -// "com.sun.xml.ws.client.ContentNegotiation";
> -
> }
>
> File [changed]: ContentNegotiation.java
> Url: https://jax-ws-sources.dev.java.net/source/browse/jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/client/ContentNegotiation.java?r1=1.5&r2=1.5.2.1
> Delta lines: +40 -37
> ---------------------
> --- ContentNegotiation.java 3 Nov 2005 19:05:44 -0000 1.5
> +++ ContentNegotiation.java 4 Apr 2006 15:14:58 -0000 1.5.2.1
> @@ -17,49 +17,52 @@
> * own identifying information: Portions Copyright [yyyy]
> * [name of copyright owner]
> */
> -
> package com.sun.xml.ws.client;
>
> -import com.sun.xml.ws.pept.presentation.MessageStruct;
> -import static com.sun.xml.ws.client.BindingProviderProperties.CONTENT_NEGOTIATION_PROPERTY;
> -
> -import java.util.Map;
> -
> -public class ContentNegotiation {
> +/**
> + * Content negotiation enum.
> + * <p>
> + * A value of {_at_link #none} means no content negotation at level of the
> + * client transport will be performed to negotiate the encoding of XML infoset.
> + * The default encoding will always be used.
> + * <p>
> + * A value of {_at_link #pessimistic} means the client transport will assume
> + * the default encoding of XML infoset for an outbound message unless informed
> + * otherwise by a previously received inbound message.
> + * (The client transport initially and pessimistically assumes that a service
> + * does not support anything other than the default encoding of XML infoset.)
> + * <p>
> + * A value of {_at_link #optimistic} means the client transport will assume
> + * a non-default encoding of XML infoset for an outbound message.
> + * (The client transport optimistically assumes that a service
> + * supports the non-default encoding of XML infoset.)
> + *
> + * @author Paul.Sandoz_at_Sun.Com
> + */
> +public enum ContentNegotiation {
> + none,
> + pessimistic,
> + optimistic;
>
> /**
> - * Initializes content negotiation property in <code>MessageStruct</code>
> - * based on request context and system properties.
> + * Property name for content negotiation on a {_at_link RequestContext} and
> + * a {_at_link Packet}.
> */
> - static public void initialize(Map context, MessageStruct messageStruct) {
> - String value = (String) context.get(CONTENT_NEGOTIATION_PROPERTY);
> - if (value != null) {
> - if (value.equals("none") || value.equals("pessimistic") || value.equals("optimistic")) {
> - messageStruct.setMetaData(CONTENT_NEGOTIATION_PROPERTY, value.intern());
> - } else {
> - throw new SenderException("sender.request.illegalValueForContentNegotiation", value);
> - }
> - } else {
> - initFromSystemProperties(context, messageStruct);
> - }
> - }
> + public static final String PROPERTY = "com.sun.xml.ws.client.ContentNegotiation";
>
> /**
> - * Initializes content negotiation property in <code>MessageStruct</code>
> - * based on system property of the same name.
> + * Obtain the content negiation value from a system property.
> + * @return the content negotiation value.
> */
> - static public void initFromSystemProperties(Map context, MessageStruct messageStruct)
> - throws SenderException {
> - String value = System.getProperty(CONTENT_NEGOTIATION_PROPERTY);
> -
> - if (value == null) {
> - messageStruct.setMetaData(
> - CONTENT_NEGOTIATION_PROPERTY, "none"); // FI is off by default
> - } else if (value.equals("none") || value.equals("pessimistic") || value.equals("optimistic")) {
> - messageStruct.setMetaData(CONTENT_NEGOTIATION_PROPERTY, value.intern());
> - context.put(CONTENT_NEGOTIATION_PROPERTY, value.intern());
> - } else {
> - throw new SenderException("sender.request.illegalValueForContentNegotiation", value);
> + public static ContentNegotiation obtainFromSystemProperty() {
> + String value = System.getProperty(PROPERTY);
> + try {
> + if (value == null) return none;
> +
> + return valueOf(value);
> + } catch (IllegalArgumentException e) {
> + // Default to none for any unrecognized value
> + return none;
> }
> }
> }
>
> Directory: /jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/api/message/
> ======================================================================
>
> File [changed]: Packet.java
> Url: https://jax-ws-sources.dev.java.net/source/browse/jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/api/message/Packet.java?r1=1.1.2.11&r2=1.1.2.12
> Delta lines: +11 -0
> --------------------
> --- Packet.java 23 Mar 2006 22:04:47 -0000 1.1.2.11
> +++ Packet.java 4 Apr 2006 15:14:58 -0000 1.1.2.12
> @@ -27,6 +27,7 @@
> import com.sun.xml.ws.client.BindingProviderProperties;
> import com.sun.xml.ws.api.server.TransportBackChannel;
> import com.sun.xml.ws.api.server.WebServiceContextDelegate;
> +import com.sun.xml.ws.client.ContentNegotiation;
> import com.sun.xml.ws.util.PropertySet;
>
> import javax.xml.ws.BindingProvider;
> @@ -372,6 +373,16 @@
> @Deprecated
> public Boolean isOneWay;
>
> + /**
> + * The value of {_at_link ContentNegotiation#PROPERTY}
> + * property.
> + * <p>
> + * This property is only used for outbound messages.
> + */
> + @Property(ContentNegotiation.PROPERTY)
> + public ContentNegotiation contentNegotiation = ContentNegotiation.none;
> +
> +
> /**
> * Bag to capture "other" properties that do not have
> * strongly-typed presence on this object.
>
> Directory: /jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/developer/
> ====================================================================
>
> File [changed]: JAXWSProperties.java
> Url: https://jax-ws-sources.dev.java.net/source/browse/jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/developer/JAXWSProperties.java?r1=1.5&r2=1.5.2.1
> Delta lines: +1 -0
> -------------------
> --- JAXWSProperties.java 1 Dec 2005 03:41:38 -0000 1.5
> +++ JAXWSProperties.java 4 Apr 2006 15:14:59 -0000 1.5.2.1
> @@ -21,6 +21,7 @@
>
> public interface JAXWSProperties {
> // Content negotiation property: values "none", "pessimistic" and "optimistic"
> + @Deprecated
> public static final String CONTENT_NEGOTIATION_PROPERTY = "com.sun.xml.ws.client.ContentNegotiation";
> public static final String MTOM_THRESHOLOD_VALUE = "com.sun.xml.ws.common.MtomThresholdValue";
> public static final String HTTP_EXCHANGE = "com.sun.xml.ws.http.exchange";
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cvs-unsubscribe_at_jax-ws-sources.dev.java.net
> For additional commands, e-mail: cvs-help_at_jax-ws-sources.dev.java.net
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com