|
1 /* |
|
2 * Copyright (c) 1997, 2010, 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 |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package com.sun.xml.internal.ws.client.dispatch; |
|
27 |
|
28 import com.sun.xml.internal.ws.api.addressing.WSEndpointReference; |
|
29 import com.sun.xml.internal.ws.api.message.Message; |
|
30 import com.sun.xml.internal.ws.api.message.Messages; |
|
31 import com.sun.xml.internal.ws.api.message.Packet; |
|
32 import com.sun.xml.internal.ws.api.pipe.Tube; |
|
33 import com.sun.xml.internal.ws.api.client.WSPortInfo; |
|
34 import com.sun.xml.internal.ws.binding.BindingImpl; |
|
35 import com.sun.xml.internal.ws.client.WSServiceDelegate; |
|
36 import com.sun.xml.internal.ws.client.PortInfo; |
|
37 import com.sun.xml.internal.ws.message.source.PayloadSourceMessage; |
|
38 |
|
39 import javax.xml.namespace.QName; |
|
40 import javax.xml.transform.Source; |
|
41 import javax.xml.ws.Service.Mode; |
|
42 import javax.xml.ws.WebServiceException; |
|
43 |
|
44 |
|
45 /** |
|
46 * The <code>SOAPSourceDispatch</code> class provides support |
|
47 * for the dynamic invocation of a service endpoint operation using XML |
|
48 * constructs. The <code>javax.xml.ws.Service</code> |
|
49 * interface acts as a factory for the creation of <code>SOAPSourceDispatch</code> |
|
50 * instances. |
|
51 * |
|
52 * @author WS Development Team |
|
53 * @version 1.0 |
|
54 * @see RESTSourceDispatch |
|
55 */ |
|
56 final class SOAPSourceDispatch extends DispatchImpl<Source> { |
|
57 @Deprecated |
|
58 public SOAPSourceDispatch(QName port, Mode mode, WSServiceDelegate owner, Tube pipe, BindingImpl binding, WSEndpointReference epr) { |
|
59 super(port, mode, owner, pipe, binding, epr); |
|
60 assert !isXMLHttp(binding); |
|
61 } |
|
62 |
|
63 public SOAPSourceDispatch(WSPortInfo portInfo, Mode mode, BindingImpl binding, WSEndpointReference epr) { |
|
64 super(portInfo, mode, binding, epr); |
|
65 assert !isXMLHttp(binding); |
|
66 } |
|
67 |
|
68 |
|
69 Source toReturnValue(Packet response) { |
|
70 Message msg = response.getMessage(); |
|
71 |
|
72 switch (mode) { |
|
73 case PAYLOAD: |
|
74 return msg.readPayloadAsSource(); |
|
75 case MESSAGE: |
|
76 return msg.readEnvelopeAsSource(); |
|
77 default: |
|
78 throw new WebServiceException("Unrecognized dispatch mode"); |
|
79 } |
|
80 } |
|
81 |
|
82 @Override |
|
83 Packet createPacket(Source msg) { |
|
84 |
|
85 final Message message; |
|
86 |
|
87 if (msg == null) |
|
88 message = Messages.createEmpty(soapVersion); |
|
89 else { |
|
90 switch (mode) { |
|
91 case PAYLOAD: |
|
92 message = new PayloadSourceMessage(null, msg, setOutboundAttachments(), soapVersion); |
|
93 break; |
|
94 case MESSAGE: |
|
95 message = Messages.create(msg, soapVersion); |
|
96 break; |
|
97 default: |
|
98 throw new WebServiceException("Unrecognized message mode"); |
|
99 } |
|
100 } |
|
101 |
|
102 return new Packet(message); |
|
103 } |
|
104 |
|
105 |
|
106 } |