com.sun.xml.ws.addressing.WsaActionUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rt Show documentation
Show all versions of rt Show documentation
JAX-WS Reference Implementation Runtime
The newest version!
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package com.sun.xml.ws.addressing;
import com.sun.xml.ws.api.model.CheckedException;
import com.sun.xml.ws.api.model.JavaMethod;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Logger;
/**
* @author Rama Pulavarthi
*/
public final class WsaActionUtil {
private WsaActionUtil() {}
@SuppressWarnings("FinalStaticMethod")
public static final String getDefaultFaultAction(JavaMethod method, CheckedException ce) {
String tns = method.getOwner().getTargetNamespace();
String delim = getDelimiter(tns);
if (tns.endsWith(delim)) {
tns = tns.substring(0, tns.length() - 1);
}
return new StringBuilder(tns).append(delim).append(
method.getOwner().getPortTypeName().getLocalPart()).append(
delim).append(method.getOperationName()).append(delim).append("Fault").append(delim).append(ce.getExceptionClass().getSimpleName()).toString();
}
private static String getDelimiter(String tns) {
String delim = "/";
// TODO: is this the correct way to find the separator ?
try {
URI uri = new URI(tns);
if ((uri.getScheme() != null) && uri.getScheme().equalsIgnoreCase("urn")) {
delim = ":";
}
} catch (URISyntaxException e) {
LOGGER.warning("TargetNamespace of WebService is not a valid URI");
}
return delim;
}
private static final Logger LOGGER =
Logger.getLogger(WsaActionUtil.class.getName());
}