1 /* |
1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
26 package com.sun.xml.internal.ws.wsdl; |
26 package com.sun.xml.internal.ws.wsdl; |
27 |
27 |
28 import com.sun.istack.internal.Nullable; |
28 import com.sun.istack.internal.Nullable; |
29 import com.sun.xml.internal.ws.api.WSBinding; |
29 import com.sun.xml.internal.ws.api.WSBinding; |
30 import com.sun.xml.internal.ws.api.model.SEIModel; |
30 import com.sun.xml.internal.ws.api.model.SEIModel; |
|
31 import com.sun.xml.internal.ws.api.model.WSDLOperationMapping; |
31 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; |
32 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; |
32 import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation; |
33 import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation; |
33 import com.sun.xml.internal.ws.api.message.Message; |
34 import com.sun.xml.internal.ws.api.message.Message; |
34 import com.sun.xml.internal.ws.api.message.Packet; |
35 import com.sun.xml.internal.ws.api.message.Packet; |
35 import com.sun.xml.internal.ws.fault.SOAPFaultBuilder; |
36 import com.sun.xml.internal.ws.fault.SOAPFaultBuilder; |
60 |
61 |
61 public static final String EMPTY_PAYLOAD_LOCAL = ""; |
62 public static final String EMPTY_PAYLOAD_LOCAL = ""; |
62 public static final String EMPTY_PAYLOAD_NSURI = ""; |
63 public static final String EMPTY_PAYLOAD_NSURI = ""; |
63 public static final QName EMPTY_PAYLOAD = new QName(EMPTY_PAYLOAD_NSURI, EMPTY_PAYLOAD_LOCAL); |
64 public static final QName EMPTY_PAYLOAD = new QName(EMPTY_PAYLOAD_NSURI, EMPTY_PAYLOAD_LOCAL); |
64 |
65 |
65 private final QNameMap<QName> methodHandlers = new QNameMap<QName>(); |
66 private final QNameMap<WSDLOperationMapping> methodHandlers = new QNameMap<WSDLOperationMapping>(); |
66 private final QNameMap<List<String>> unique = new QNameMap<List<String>>(); |
67 private final QNameMap<List<String>> unique = new QNameMap<List<String>>(); |
67 |
68 |
68 |
69 |
69 public PayloadQNameBasedOperationFinder(WSDLPort wsdlModel, WSBinding binding, @Nullable SEIModel seiModel) { |
70 public PayloadQNameBasedOperationFinder(WSDLPort wsdlModel, WSBinding binding, @Nullable SEIModel seiModel) { |
70 super(wsdlModel,binding,seiModel); |
71 super(wsdlModel,binding,seiModel); |
96 if (name == null) |
97 if (name == null) |
97 name = EMPTY_PAYLOAD; |
98 name = EMPTY_PAYLOAD; |
98 // Set up method handlers only for unique QNames. So that dispatching |
99 // Set up method handlers only for unique QNames. So that dispatching |
99 // happens consistently for a method |
100 // happens consistently for a method |
100 if (unique.get(name).size() == 1) { |
101 if (unique.get(name).size() == 1) { |
101 methodHandlers.put(name, m.getOperationQName()); |
102 methodHandlers.put(name, wsdlOperationMapping(m)); |
102 } |
103 } |
103 } |
104 } |
104 } else { |
105 } else { |
105 for (WSDLBoundOperation wsdlOp : wsdlModel.getBinding().getBindingOperations()) { |
106 for (WSDLBoundOperation wsdlOp : wsdlModel.getBinding().getBindingOperations()) { |
106 QName name = wsdlOp.getReqPayloadName(); |
107 QName name = wsdlOp.getReqPayloadName(); |
107 if (name == null) |
108 if (name == null) |
108 name = EMPTY_PAYLOAD; |
109 name = EMPTY_PAYLOAD; |
109 methodHandlers.put(name, wsdlOp.getName()); |
110 methodHandlers.put(name, wsdlOperationMapping(wsdlOp)); |
110 } |
111 } |
111 } |
112 } |
112 } |
113 } |
113 |
114 |
114 /** |
115 /** |
117 * null if it cannot idenitify a unique wsdl operation from the Payload QName. |
118 * null if it cannot idenitify a unique wsdl operation from the Payload QName. |
118 * |
119 * |
119 * @throws DispatchException if the payload itself is incorrect, this happens when the payload is not accepted by |
120 * @throws DispatchException if the payload itself is incorrect, this happens when the payload is not accepted by |
120 * any operation in the port. |
121 * any operation in the port. |
121 */ |
122 */ |
122 public QName getWSDLOperationQName(Packet request) throws DispatchException{ |
123 // public QName getWSDLOperationQName(Packet request) throws DispatchException{ |
|
124 |
|
125 public WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException { |
123 Message message = request.getMessage(); |
126 Message message = request.getMessage(); |
124 String localPart = message.getPayloadLocalPart(); |
127 String localPart = message.getPayloadLocalPart(); |
125 String nsUri; |
128 String nsUri; |
126 if (localPart == null) { |
129 if (localPart == null) { |
127 localPart = EMPTY_PAYLOAD_LOCAL; |
130 localPart = EMPTY_PAYLOAD_LOCAL; |
129 } else { |
132 } else { |
130 nsUri = message.getPayloadNamespaceURI(); |
133 nsUri = message.getPayloadNamespaceURI(); |
131 if(nsUri == null) |
134 if(nsUri == null) |
132 nsUri = EMPTY_PAYLOAD_NSURI; |
135 nsUri = EMPTY_PAYLOAD_NSURI; |
133 } |
136 } |
134 QName op = methodHandlers.get(nsUri, localPart); |
137 WSDLOperationMapping op = methodHandlers.get(nsUri, localPart); |
135 |
138 |
136 // Check if payload itself is correct. Usually it is, so let us check last |
139 // Check if payload itself is correct. Usually it is, so let us check last |
137 if (op == null && !unique.containsKey(nsUri,localPart)) { |
140 if (op == null && !unique.containsKey(nsUri,localPart)) { |
138 String dispatchKey = "{" + nsUri + "}" + localPart; |
141 String dispatchKey = "{" + nsUri + "}" + localPart; |
139 String faultString = ServerMessages.DISPATCH_CANNOT_FIND_METHOD(dispatchKey); |
142 String faultString = ServerMessages.DISPATCH_CANNOT_FIND_METHOD(dispatchKey); |