1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
25
26 package com.sun.xml.internal.ws.binding;
27
28 import com.sun.istack.internal.NotNull;
29 import com.sun.xml.internal.ws.api.BindingID;
30 import com.sun.xml.internal.ws.api.SOAPVersion;
31 import com.sun.xml.internal.ws.client.HandlerConfiguration;
32 import com.sun.xml.internal.ws.encoding.soap.streaming.SOAP12NamespaceConstants;
33 import com.sun.xml.internal.ws.resources.ClientMessages;
34
35 import javax.xml.namespace.QName;
36 import javax.xml.soap.MessageFactory;
37 import javax.xml.soap.SOAPFactory;
38
39 import javax.xml.ws.WebServiceException;
40 import javax.xml.ws.WebServiceFeature;
41 import javax.xml.ws.handler.Handler;
42 import javax.xml.ws.soap.MTOMFeature;
43 import javax.xml.ws.soap.SOAPBinding;
44 import java.util.*;
45
46 /**
47 * @author WS Development Team
48 */
49 public final class SOAPBindingImpl extends BindingImpl implements SOAPBinding {
50
51 public static final String X_SOAP12HTTP_BINDING =
52 "http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/";
53
54 private static final String ROLE_NONE = SOAP12NamespaceConstants.ROLE_NONE;
55 //protected boolean enableMtom;
56 protected final SOAPVersion soapVersion;
57
58 private Set<QName> portKnownHeaders = Collections.emptySet();
59 private Set<QName> bindingUnderstoodHeaders = new HashSet<QName>();
60
61 /**
62 * Use {@link BindingImpl#create(BindingID)} to create this.
63 *
64 * @param bindingId SOAP binding ID
65 */
66 SOAPBindingImpl(BindingID bindingId) {
67 this(bindingId,EMPTY_FEATURES);
68 }
69
70 /**
71 * Use {@link BindingImpl#create(BindingID)} to create this.
72 *
73 * @param bindingId binding id
74 * @param features
75 * These features have a precedence over
76 * {@link BindingID#createBuiltinFeatureList() the implicit features}
77 * associated with the {@link BindingID}.
78 */
79 SOAPBindingImpl(BindingID bindingId, WebServiceFeature... features) {
80 super(bindingId, features);
81 this.soapVersion = bindingId.getSOAPVersion();
82 //populates with required roles and updates handlerConfig
83 setRoles(new HashSet<String>());
84 //Is this still required? comment out for now
85 //setupSystemHandlerDelegate(serviceName);
86
87 this.features.addAll(bindingId.createBuiltinFeatureList());
88 }
89
90 /**
91 * This method should be called if the binding has SOAPSEIModel
92 * The Headers understood by the Port are set, so that they can be used for MU
93 * processing.
94 *
95 * @param headers SOAP header names
96 */
97 public void setPortKnownHeaders(@NotNull Set<QName> headers) {
98 this.portKnownHeaders = headers;
99 }
100
101 /**
102 * TODO A feature should be created to configure processing of MU headers.
103 * @param header
104 * @return
105 */
106 public boolean understandsHeader(QName header) {
107 return serviceMode == javax.xml.ws.Service.Mode.MESSAGE
108 || portKnownHeaders.contains(header)
109 || bindingUnderstoodHeaders.contains(header);
110
111 }
112
113 /**
114 * Sets the handlers on the binding and then sorts the handlers in to logical and protocol handlers.
115 * Creates a new HandlerConfiguration object and sets it on the BindingImpl. Also parses Headers understood by
116 * Protocol Handlers and sets the HandlerConfiguration.
117 */
118 public void setHandlerChain(List<Handler> chain) {
|
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
25
26 package com.sun.xml.internal.ws.binding;
27
28 import com.sun.istack.internal.NotNull;
29 import com.sun.xml.internal.ws.api.BindingID;
30 import com.sun.xml.internal.ws.api.SOAPVersion;
31 import com.sun.xml.internal.ws.client.HandlerConfiguration;
32 import com.sun.xml.internal.ws.encoding.soap.streaming.SOAP12NamespaceConstants;
33 import com.sun.xml.internal.ws.resources.ClientMessages;
34
35 import javax.xml.namespace.QName;
36 import javax.xml.soap.MessageFactory;
37 import javax.xml.soap.SOAPFactory;
38
39 import javax.xml.ws.WebServiceException;
40 import javax.xml.ws.WebServiceFeature;
41 import javax.xml.ws.handler.Handler;
42 import javax.xml.ws.soap.MTOMFeature;
43 import javax.xml.ws.soap.SOAPBinding;
44 import java.util.*;
45 import java.util.concurrent.locks.Lock;
46 import java.util.concurrent.locks.ReentrantLock;
47
48 /**
49 * @author WS Development Team
50 */
51 public final class SOAPBindingImpl extends BindingImpl implements SOAPBinding {
52
53 public static final String X_SOAP12HTTP_BINDING =
54 "http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/";
55
56 private static final String ROLE_NONE = SOAP12NamespaceConstants.ROLE_NONE;
57 //protected boolean enableMtom;
58 protected final SOAPVersion soapVersion;
59
60 private Set<QName> portKnownHeaders = Collections.emptySet();
61 private Set<QName> bindingUnderstoodHeaders = new HashSet<QName>();
62 private final Lock lock = new ReentrantLock();
63
64 /**
65 * Use {@link BindingImpl#create(BindingID)} to create this.
66 *
67 * @param bindingId SOAP binding ID
68 */
69 SOAPBindingImpl(BindingID bindingId) {
70 this(bindingId,EMPTY_FEATURES);
71 }
72
73 /**
74 * Use {@link BindingImpl#create(BindingID)} to create this.
75 *
76 * @param bindingId binding id
77 * @param features
78 * These features have a precedence over
79 * {@link BindingID#createBuiltinFeatureList() the implicit features}
80 * associated with the {@link BindingID}.
81 */
82 SOAPBindingImpl(BindingID bindingId, WebServiceFeature... features) {
83 super(bindingId, features);
84 this.soapVersion = bindingId.getSOAPVersion();
85 //populates with required roles and updates handlerConfig
86 setRoles(new HashSet<String>());
87 //Is this still required? comment out for now
88 //setupSystemHandlerDelegate(serviceName);
89
90 this.features.addAll(bindingId.createBuiltinFeatureList());
91 }
92
93 /**
94 * This method should be called if the binding has SOAPSEIModel
95 * The Headers understood by the Port are set, so that they can be used for MU
96 * processing.
97 *
98 * @param headers SOAP header names
99 */
100 public void setPortKnownHeaders(@NotNull Set<QName> headers) {
101
102 try{
103 lock.lock();
104 this.portKnownHeaders = headers;
105 } finally {
106 lock.unlock();
107 }
108 }
109
110 /**
111 * TODO A feature should be created to configure processing of MU headers.
112 * @param header
113 * @return
114 */
115 public boolean understandsHeader(QName header) {
116 return serviceMode == javax.xml.ws.Service.Mode.MESSAGE
117 || portKnownHeaders.contains(header)
118 || bindingUnderstoodHeaders.contains(header);
119
120 }
121
122 /**
123 * Sets the handlers on the binding and then sorts the handlers in to logical and protocol handlers.
124 * Creates a new HandlerConfiguration object and sets it on the BindingImpl. Also parses Headers understood by
125 * Protocol Handlers and sets the HandlerConfiguration.
126 */
127 public void setHandlerChain(List<Handler> chain) {
|