document
style
ohair@286: * soapBindings
ohair@286: */
ohair@286: private static final String DOCUMENT = "document";
ohair@286: /**
ohair@286: * Constant String "rpc" used to specify rpc
style
ohair@286: * soapBindings
ohair@286: */
ohair@286: private static final String RPC = "rpc";
ohair@286: /**
ohair@286: * Constant String "literal" used to create literal
use binddings
ohair@286: */
ohair@286: private static final String LITERAL = "literal";
ohair@286: /**
ohair@286: * Constant String to flag the URL to replace at runtime for the endpoint
ohair@286: */
ohair@286: private static final String REPLACE_WITH_ACTUAL_URL = "REPLACE_WITH_ACTUAL_URL";
ohair@286: private Setmethod
is wrapper style
ohair@286: * @param method The {@link JavaMethod} to check if it is wrapper style
ohair@286: * @return true if the method is wrapper style, otherwise, false.
ohair@286: */
ohair@286: protected boolean isWrapperStyle(JavaMethodImpl method) {
ohair@286: if (method.getRequestParameters().size() > 0) {
ohair@286: ParameterImpl param = method.getRequestParameters().iterator().next();
ohair@286: return param.isWrapperStyle();
ohair@286: }
ohair@286: return false;
ohair@286: }
ohair@286:
ohair@286: /**
ohair@286: * Determines if a {@link JavaMethod} is rpc/literal
ohair@286: * @param method The method to check
ohair@286: * @return true if method is rpc/literal, otherwise, false
ohair@286: */
ohair@286: protected boolean isRpcLit(JavaMethodImpl method) {
ohair@286: return method.getBinding().getStyle() == Style.RPC;
ohair@286: }
ohair@286:
ohair@286: /**
ohair@286: * Generates the parameterOrder for a PortType operation
ohair@286: * @param operation The operation to generate the parameterOrder for
ohair@286: * @param method The {@link JavaMethod} to generate the parameterOrder from
ohair@286: */
ohair@286: protected void generateParameterOrder(Operation operation, JavaMethodImpl method) {
ohair@286: if (method.getMEP() == MEP.ONE_WAY)
ohair@286: return;
ohair@286: if (isRpcLit(method))
ohair@286: generateRpcParameterOrder(operation, method);
ohair@286: else
ohair@286: generateDocumentParameterOrder(operation, method);
ohair@286: }
ohair@286:
ohair@286: /**
ohair@286: * Generates the parameterOrder for a PortType operation
ohair@286: * @param operation the operation to generate the parameterOrder for
ohair@286: * @param method the {@link JavaMethod} to generate the parameterOrder from
ohair@286: */
ohair@286: protected void generateRpcParameterOrder(Operation operation, JavaMethodImpl method) {
ohair@286: String partName;
alanb@368: StringBuilder paramOrder = new StringBuilder();
ohair@286: Setbody
parameter
ohair@286: */
ohair@286: protected boolean isBodyParameter(ParameterImpl parameter) {
ohair@286: ParameterBinding paramBinding = parameter.getBinding();
ohair@286: return paramBinding.isBody();
ohair@286: }
ohair@286:
ohair@286: protected boolean isHeaderParameter(ParameterImpl parameter) {
ohair@286: ParameterBinding paramBinding = parameter.getBinding();
ohair@286: return paramBinding.isHeader();
ohair@286: }
ohair@286:
ohair@286: protected boolean isAttachmentParameter(ParameterImpl parameter) {
ohair@286: ParameterBinding paramBinding = parameter.getBinding();
ohair@286: return paramBinding.isAttachment();
ohair@286: }
ohair@286:
ohair@286:
ohair@286: /**
ohair@286: * Generates the Binding section of the WSDL
ohair@286: */
ohair@286: protected void generateBinding() {
alanb@368: Binding newBinding = serviceDefinitions.binding().name(model.getBoundPortTypeName().getLocalPart());
alanb@368: extension.addBindingExtension(newBinding);
alanb@368: newBinding.type(model.getPortTypeName());
ohair@286: boolean first = true;
ohair@286: for (JavaMethodImpl method : model.getJavaMethods()) {
ohair@286: if (first) {
ohair@286: SOAPBinding sBinding = method.getBinding();
ohair@286: SOAPVersion soapVersion = sBinding.getSOAPVersion();
ohair@286: if (soapVersion == SOAPVersion.SOAP_12) {
alanb@368: com.sun.xml.internal.ws.wsdl.writer.document.soap12.SOAPBinding soapBinding = newBinding.soap12Binding();
ohair@286: soapBinding.transport(this.binding.getBindingId().getTransport());
ohair@286: if (sBinding.getStyle().equals(Style.DOCUMENT))
ohair@286: soapBinding.style(DOCUMENT);
ohair@286: else
ohair@286: soapBinding.style(RPC);
ohair@286: } else {
alanb@368: com.sun.xml.internal.ws.wsdl.writer.document.soap.SOAPBinding soapBinding = newBinding.soapBinding();
ohair@286: soapBinding.transport(this.binding.getBindingId().getTransport());
ohair@286: if (sBinding.getStyle().equals(Style.DOCUMENT))
ohair@286: soapBinding.style(DOCUMENT);
ohair@286: else
ohair@286: soapBinding.style(RPC);
ohair@286: }
ohair@286: first = false;
ohair@286: }
ohair@286: if (this.binding.getBindingId().getSOAPVersion() == SOAPVersion.SOAP_12)
alanb@368: generateSOAP12BindingOperation(method, newBinding);
ohair@286: else
alanb@368: generateBindingOperation(method, newBinding);
ohair@286: }
ohair@286: }
ohair@286:
ohair@286: protected void generateBindingOperation(JavaMethodImpl method, Binding binding) {
ohair@286: BindingOperationType operation = binding.operation().name(method.getOperationName());
ohair@286: extension.addBindingOperationExtension(operation, method);
ohair@286: String targetNamespace = model.getTargetNamespace();
ohair@286: QName requestMessage = new QName(targetNamespace, method.getOperationName());
ohair@286: Listohair@286: * For example, {@code relative("http://www.sun.com/abc/def","http://www.sun.com/pqr/stu") => "../abc/def"} ohair@286: * ohair@286: *
ohair@286: * This method only works on hierarchical URI's, not opaque URI's (refer to the ohair@286: * java.net.URI ohair@286: * javadoc for complete definitions of these terms. ohair@286: * ohair@286: *
ohair@286: * This method will not normalize the relative URI.
ohair@286: * @param uri the URI to relativize
ohair@286: *
ohair@286: *
ohair@286: * @param baseUri the base URI to use for the relativization
ohair@286: * @return the relative URI or the original URI if a relative one could not be computed
ohair@286: */
ohair@286: protected static String relativize(String uri, String baseUri) {
ohair@286: try {
ohair@286: assert uri != null;
ohair@286:
ohair@286: if (baseUri == null) return uri;
ohair@286:
ohair@286: URI theUri = new URI(escapeURI(uri));
ohair@286: URI theBaseUri = new URI(escapeURI(baseUri));
ohair@286:
ohair@286: if (theUri.isOpaque() || theBaseUri.isOpaque())
ohair@286: return uri;
ohair@286:
ohair@286: if (!equalsIgnoreCase(theUri.getScheme(), theBaseUri.getScheme()) ||
ohair@286: !equal(theUri.getAuthority(), theBaseUri.getAuthority()))
ohair@286: return uri;
ohair@286:
ohair@286: String uriPath = theUri.getPath();
ohair@286: String basePath = theBaseUri.getPath();
ohair@286:
ohair@286: // normalize base path
ohair@286: if (!basePath.endsWith("/")) {
ohair@286: basePath = normalizeUriPath(basePath);
ohair@286: }
ohair@286:
ohair@286: if (uriPath.equals(basePath))
ohair@286: return ".";
ohair@286:
ohair@286: String relPath = calculateRelativePath(uriPath, basePath);
ohair@286:
ohair@286: if (relPath == null)
ohair@286: return uri; // recursion found no commonality in the two uris at all
alanb@368: StringBuilder relUri = new StringBuilder();
ohair@286: relUri.append(relPath);
ohair@286: if (theUri.getQuery() != null)
ohair@286: relUri.append('?').append(theUri.getQuery());
ohair@286: if (theUri.getFragment() != null)
ohair@286: relUri.append('#').append(theUri.getFragment());
ohair@286:
ohair@286: return relUri.toString();
ohair@286: } catch (URISyntaxException e) {
ohair@286: throw new InternalError("Error escaping one of these uris:\n\t" + uri + "\n\t" + baseUri);
ohair@286: }
ohair@286: }
ohair@286:
ohair@286: private static String calculateRelativePath(String uri, String base) {
ohair@286: if (base == null) {
ohair@286: return null;
ohair@286: }
ohair@286: if (uri.startsWith(base)) {
ohair@286: return uri.substring(base.length());
ohair@286: } else {
ohair@286: return "../" + calculateRelativePath(uri, getParentUriPath(base));
ohair@286: }
ohair@286: }
ohair@286:
ohair@286:
ohair@286: /**
ohair@286: * Implements the SchemaOutputResolver used by JAXB to
ohair@286: */
ohair@286: protected class JAXWSOutputSchemaResolver extends SchemaOutputResolver {
ohair@286: ArrayList