feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,87 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.fault;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.namespace.QName;
/**
* <pre>
* &lt;env:Code>
* &lt;env:Value>env:Sender&lt;/env:Value>
* &lt;env:Subcode>
* &lt;env:Value>m:MessageTimeout1&lt;/env:Value>
* &lt;env:Subcode>
* &lt;env:Value>m:MessageTimeout2&lt;/env:Value>
* &lt;/env:Subcode>
* &lt;/env:Subcode>
* &lt;/env:Code>
* </pre>
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CodeType", namespace = "http://www.w3.org/2003/05/soap-envelope", propOrder = {
"Value",
"Subcode"
})
class CodeType {
@XmlTransient
private static final String ns="http://www.w3.org/2003/05/soap-envelope";
/**
* mandatory, minOccurs=1
*/
@XmlElement(namespace = ns)
private QName Value;
/**
* optional, minOcccurs=0, maxOccurs="1"
*/
@XmlElement(namespace = ns)
private SubcodeType Subcode;
CodeType(QName value) {
Value = value;
}
CodeType() {
}
QName getValue(){
return Value;
}
SubcodeType getSubcode(){
return Subcode;
}
void setSubcode(SubcodeType subcode) {
Subcode = subcode;
}
}

View File

@@ -0,0 +1,82 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.fault;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import javax.xml.bind.annotation.XmlAnyElement;
import java.util.ArrayList;
import java.util.List;
/**
* &lt;env:Detail>
* &lt;m:MaxTime>P5M</m:MaxTime>
* &lt;/env:Detail>
*/
class DetailType {
/**
* The detail entry could be 0 or more elements. Perhaps some elements may be
* known to JAXB while others can be handled using DOMHandler.
*
* Even though the jaxbContext is aware of the detail jaxbBean but we get the list of
* {@link org.w3c.dom.Node}s.
*
* this is because since we unmarshall using {@link com.sun.xml.internal.bind.api.Bridge} all we're
* going to get during unmarshalling is {@link org.w3c.dom.Node} and not the jaxb bean instances.
*
* TODO: For now detailEntry would be List of Node isntead of Object and it needs to be changed to
* {@link Object} once we have better solution that working thru {@link com.sun.xml.internal.bind.api.Bridge}
*/
@XmlAnyElement
private final List<Element> detailEntry = new ArrayList<Element>();
@NotNull
List<Element> getDetails() {
return detailEntry;
}
/**
* Gets the n-th detail object, or null if no such item exists.
*/
@Nullable
Node getDetail(int n) {
if(n < detailEntry.size())
return detailEntry.get(n);
else
return null;
}
DetailType(Element detailObject) {
if(detailObject != null)
detailEntry.add(detailObject);
}
DetailType() {
}
}

View File

@@ -0,0 +1,200 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.fault;
import com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper;
import com.sun.xml.internal.ws.developer.ServerSideException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.PropertyException;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;
/**
* JAXB-bound bean that captures the exception and its call stack.
*
* <p>
* This is used to capture the stack trace of the server side error and
* send that over to the client.
*
* @author Kohsuke Kawaguchi
*/
@XmlRootElement(namespace=ExceptionBean.NS,name=ExceptionBean.LOCAL_NAME)
final class ExceptionBean {
/**
* Converts the given {@link Throwable} into an XML representation
* and put that as a DOM tree under the given node.
*/
public static void marshal( Throwable t, Node parent ) throws JAXBException {
Marshaller m = JAXB_CONTEXT.createMarshaller();
try {
m.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper",nsp);
} catch (PropertyException pe) {}
m.marshal(new ExceptionBean(t), parent );
}
/**
* Does the reverse operation of {@link #marshal(Throwable, Node)}. Constructs an
* {@link Exception} object from the XML.
*/
public static ServerSideException unmarshal( Node xml ) throws JAXBException {
ExceptionBean e = (ExceptionBean) JAXB_CONTEXT.createUnmarshaller().unmarshal(xml);
return e.toException();
}
@XmlAttribute(name="class")
public String className;
@XmlElement
public String message;
@XmlElementWrapper(namespace=NS,name="stackTrace")
@XmlElement(namespace=NS,name="frame")
public List<StackFrame> stackTrace = new ArrayList<StackFrame>();
@XmlElement(namespace=NS,name="cause")
public ExceptionBean cause;
// so that people noticed this fragment can turn it off
@XmlAttribute
public String note = "To disable this feature, set "+SOAPFaultBuilder.CAPTURE_STACK_TRACE_PROPERTY+" system property to false";
ExceptionBean() {// for JAXB
}
/**
* Creates an {@link ExceptionBean} tree that represents the given {@link Throwable}.
*/
private ExceptionBean(Throwable t) {
this.className = t.getClass().getName();
this.message = t.getMessage();
for (StackTraceElement f : t.getStackTrace()) {
stackTrace.add(new StackFrame(f));
}
Throwable cause = t.getCause();
if(t!=cause && cause!=null)
this.cause = new ExceptionBean(cause);
}
private ServerSideException toException() {
ServerSideException e = new ServerSideException(className,message);
if(stackTrace!=null) {
StackTraceElement[] ste = new StackTraceElement[stackTrace.size()];
for( int i=0; i<stackTrace.size(); i++ )
ste[i] = stackTrace.get(i).toStackTraceElement();
e.setStackTrace(ste);
}
if(cause!=null)
e.initCause(cause.toException());
return e;
}
/**
* Captures one stack frame.
*/
static final class StackFrame {
@XmlAttribute(name="class")
public String declaringClass;
@XmlAttribute(name="method")
public String methodName;
@XmlAttribute(name="file")
public String fileName;
@XmlAttribute(name="line")
public String lineNumber;
StackFrame() {// for JAXB
}
public StackFrame(StackTraceElement ste) {
this.declaringClass = ste.getClassName();
this.methodName = ste.getMethodName();
this.fileName = ste.getFileName();
this.lineNumber = box(ste.getLineNumber());
}
private String box(int i) {
if(i>=0) return String.valueOf(i);
if(i==-2) return "native";
return "unknown";
}
private int unbox(String v) {
try {
return Integer.parseInt(v);
} catch (NumberFormatException e) {
if ("native".equals(v)) {
return -2;
}
return -1;
}
}
private StackTraceElement toStackTraceElement() {
return new StackTraceElement(declaringClass,methodName,fileName,unbox(lineNumber));
}
}
/**
* Checks if the given element is the XML representation of {@link ExceptionBean}.
*/
public static boolean isStackTraceXml(Element n) {
return LOCAL_NAME.equals(n.getLocalName()) && NS.equals(n.getNamespaceURI());
}
private static final JAXBContext JAXB_CONTEXT;
/**
* Namespace URI.
*/
/*package*/ static final String NS = "http://jax-ws.dev.java.net/";
/*package*/ static final String LOCAL_NAME = "exception";
static {
try {
JAXB_CONTEXT = JAXBContext.newInstance(ExceptionBean.class);
} catch (JAXBException e) {
// this must be a bug in our code
throw new Error(e);
}
}
private static final NamespacePrefixMapper nsp = new NamespacePrefixMapper() {
public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {
if (NS.equals(namespaceUri)) {
return "";
}
return suggestion;
}
};
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.fault;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import java.util.ArrayList;
import java.util.List;
/**
* <pre>
* &lt;env:Reason>
* &lt;env:Text xml:lang="en">Sender Timeout</env:Text>
* &lt;/env:Reason>
* </pre>
*/
class ReasonType {
ReasonType() {
}
ReasonType(String txt) {
text.add(new TextType(txt));
}
/**
* minOccurs=1 maxOccurs=unbounded
*/
@XmlElements(@XmlElement(name = "Text", namespace = "http://www.w3.org/2003/05/soap-envelope", type = TextType.class))
private final List<TextType> text = new ArrayList<TextType>();
List<TextType> texts() {
return text;
}
}

View File

@@ -0,0 +1,183 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.fault;
import com.sun.xml.internal.ws.api.SOAPVersion;
import com.sun.xml.internal.ws.util.DOMUtil;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import javax.xml.bind.annotation.*;
import javax.xml.namespace.QName;
import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import javax.xml.ws.WebServiceException;
import java.util.Iterator;
/**
* This class represents SOAP1.1 Fault. This class will be used to marshall/unmarshall a soap fault using JAXB.
* <p/>
* <pre>
* Example:
* <p/>
* &lt;soap:Fault xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
* &lt;faultcode>soap:Client&lt;/faultcode>
* &lt;faultstring>Invalid message format&lt;/faultstring>
* &lt;faultactor>http://example.org/someactor&lt;/faultactor>
* &lt;detail>
* &lt;m:msg xmlns:m='http://example.org/faults/exceptions'>
* Test message
* &lt;/m:msg>
* &lt;/detail>
* &lt;/soap:Fault>
* <p/>
* Above, m:msg, if a known fault (described in the WSDL), IOW, if m:msg is known by JAXBContext it should be unmarshalled into a
* Java object otherwise it should be deserialized as {@link javax.xml.soap.Detail}
* </pre>
* <p/>
*
* @author Vivek Pandey
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"faultcode",
"faultstring",
"faultactor",
"detail"
})
@XmlRootElement(name = "Fault", namespace = "http://schemas.xmlsoap.org/soap/envelope/")
class SOAP11Fault extends SOAPFaultBuilder {
@XmlElement(namespace = "")
private QName faultcode;
@XmlElement(namespace = "")
private String faultstring;
@XmlElement(namespace = "")
private String faultactor;
@XmlElement(namespace = "")
private DetailType detail;
SOAP11Fault() {
}
/**
* This constructor takes soap fault detail among other things. The detail could represent {@link javax.xml.soap.Detail}
* or a java object that can be marshalled/unmarshalled by JAXB.
*
* @param code
* @param reason
* @param actor
* @param detailObject
*/
SOAP11Fault(QName code, String reason, String actor, Element detailObject) {
this.faultcode = code;
this.faultstring = reason;
this.faultactor = actor;
if (detailObject != null) {
if ((detailObject.getNamespaceURI() == null ||
"".equals(detailObject.getNamespaceURI())) && "detail".equals(detailObject.getLocalName())) {
detail = new DetailType();
for(Element detailEntry : DOMUtil.getChildElements(detailObject)) {
detail.getDetails().add(detailEntry);
}
} else {
detail = new DetailType(detailObject);
}
}
}
SOAP11Fault(SOAPFault fault) {
this.faultcode = fault.getFaultCodeAsQName();
this.faultstring = fault.getFaultString();
this.faultactor = fault.getFaultActor();
if (fault.getDetail() != null) {
detail = new DetailType();
Iterator iter = fault.getDetail().getDetailEntries();
while(iter.hasNext()){
Element fd = (Element)iter.next();
detail.getDetails().add(fd);
}
}
}
QName getFaultcode() {
return faultcode;
}
void setFaultcode(QName faultcode) {
this.faultcode = faultcode;
}
@Override
String getFaultString() {
return faultstring;
}
void setFaultstring(String faultstring) {
this.faultstring = faultstring;
}
String getFaultactor() {
return faultactor;
}
void setFaultactor(String faultactor) {
this.faultactor = faultactor;
}
/**
* returns the object that represents detail.
*/
@Override
DetailType getDetail() {
return detail;
}
void setDetail(DetailType detail) {
this.detail = detail;
}
protected Throwable getProtocolException() {
try {
SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
fault.setFaultActor(faultactor);
if(detail != null){
Detail d = fault.addDetail();
for(Element det : detail.getDetails()){
Node n = fault.getOwnerDocument().importNode(det, true);
d.appendChild(n);
}
}
return new ServerSOAPFaultException(fault);
} catch (SOAPException e) {
throw new WebServiceException(e);
}
}
}

View File

@@ -0,0 +1,249 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.fault;
import com.sun.xml.internal.ws.api.SOAPVersion;
import com.sun.xml.internal.ws.util.DOMUtil;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.soap.SOAPFaultException;
import java.util.Iterator;
/**
* SOAP 1.2 Fault class that can be marshalled/unmarshalled by JAXB
* <p/>
* <pre>
* Example:
* &lt;env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
* xmlns:m="http://www.example.org/timeouts"
* xmlns:xml="http://www.w3.org/XML/1998/namespace">
* &lt;env:Body>
* &lt;env:Fault>
* &lt;env:Code>
* &lt;env:Value>env:Sender* &lt;/env:Value>
* &lt;env:Subcode>
* &lt;env:Value>m:MessageTimeout* &lt;/env:Value>
* &lt;/env:Subcode>
* &lt;/env:Code>
* &lt;env:Reason>
* &lt;env:Text xml:lang="en">Sender Timeout* &lt;/env:Text>
* &lt;/env:Reason>
* &lt;env:Detail>
* &lt;m:MaxTime>P5M* &lt;/m:MaxTime>
* &lt;/env:Detail>
* &lt;/env:Fault>
* &lt;/env:Body>
* &lt;/env:Envelope>
* </pre>
*
* @author Vivek Pandey
*/
@XmlRootElement(name = "Fault", namespace = "http://www.w3.org/2003/05/soap-envelope")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"code",
"reason",
"node",
"role",
"detail"
})
class SOAP12Fault extends SOAPFaultBuilder {
@XmlTransient
private static final String ns = "http://www.w3.org/2003/05/soap-envelope";
@XmlElement(namespace=ns, name="Code")
private CodeType code;
@XmlElement(namespace=ns, name="Reason")
private ReasonType reason;
@XmlElement(namespace=ns, name="Node")
private String node;
@XmlElement(namespace=ns, name="Role")
private String role;
@XmlElement(namespace=ns, name="Detail")
private DetailType detail;
SOAP12Fault() {
}
SOAP12Fault(CodeType code, ReasonType reason, String node, String role, DetailType detail) {
this.code = code;
this.reason = reason;
this.node = node;
this.role = role;
this.detail = detail;
}
SOAP12Fault(CodeType code, ReasonType reason, String node, String role, Element detailObject) {
this.code = code;
this.reason = reason;
this.node = node;
this.role = role;
if (detailObject != null) {
if(detailObject.getNamespaceURI().equals(ns) && detailObject.getLocalName().equals("Detail")){
detail = new DetailType();
for(Element detailEntry : DOMUtil.getChildElements(detailObject)){
detail.getDetails().add(detailEntry);
}
}else{
detail = new DetailType(detailObject);
}
}
}
SOAP12Fault(SOAPFault fault) {
code = new CodeType(fault.getFaultCodeAsQName());
try {
fillFaultSubCodes(fault);
} catch (SOAPException e) {
throw new WebServiceException(e);
}
reason = new ReasonType(fault.getFaultString());
role = fault.getFaultRole();
node = fault.getFaultNode();
if (fault.getDetail() != null) {
detail = new DetailType();
Iterator iter = fault.getDetail().getDetailEntries();
while(iter.hasNext()){
Element fd = (Element)iter.next();
detail.getDetails().add(fd);
}
}
}
SOAP12Fault(QName code, String reason, Element detailObject) {
this(new CodeType(code), new ReasonType(reason), null, null, detailObject);
}
CodeType getCode() {
return code;
}
ReasonType getReason() {
return reason;
}
String getNode() {
return node;
}
String getRole() {
return role;
}
@Override
DetailType getDetail() {
return detail;
}
@Override
void setDetail(DetailType detail) {
this.detail = detail;
}
@Override
String getFaultString() {
return reason.texts().get(0).getText();
}
protected Throwable getProtocolException() {
try {
SOAPFault fault = SOAPVersion.SOAP_12.getSOAPFactory().createFault();;
if(reason != null){
for(TextType tt : reason.texts()){
fault.setFaultString(tt.getText());
}
}
if(code != null){
fault.setFaultCode(code.getValue());
fillFaultSubCodes(fault, code.getSubcode());
}
if(detail != null && detail.getDetail(0) != null){
javax.xml.soap.Detail detail = fault.addDetail();
for(Node obj: this.detail.getDetails()){
Node n = fault.getOwnerDocument().importNode(obj, true);
detail.appendChild(n);
}
}
if(node != null) {
fault.setFaultNode(node);
}
return new ServerSOAPFaultException(fault);
} catch (SOAPException e) {
throw new WebServiceException(e);
}
}
/**
* Recursively populate the Subcodes
*/
private void fillFaultSubCodes(SOAPFault fault, SubcodeType subcode) throws SOAPException {
if(subcode != null){
fault.appendFaultSubcode(subcode.getValue());
fillFaultSubCodes(fault, subcode.getSubcode());
}
}
/**
* Adds Fault subcodes from {@link SOAPFault} to {@link #code}
*/
private void fillFaultSubCodes(SOAPFault fault) throws SOAPException {
Iterator subcodes = fault.getFaultSubcodes();
SubcodeType firstSct = null;
while(subcodes.hasNext()){
QName subcode = (QName)subcodes.next();
if(firstSct == null){
firstSct = new SubcodeType(subcode);
code.setSubcode(firstSct);
continue;
}
SubcodeType nextSct = new SubcodeType(subcode);
firstSct.setSubcode(nextSct);
firstSct = nextSct;
}
}
}

View File

@@ -0,0 +1,601 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.fault;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.SOAPVersion;
import com.sun.xml.internal.ws.api.message.Message;
import com.sun.xml.internal.ws.api.model.ExceptionType;
import com.sun.xml.internal.ws.encoding.soap.SOAP12Constants;
import com.sun.xml.internal.ws.encoding.soap.SOAPConstants;
import com.sun.xml.internal.ws.encoding.soap.SerializationException;
import com.sun.xml.internal.ws.message.jaxb.JAXBMessage;
import com.sun.xml.internal.ws.message.FaultMessage;
import com.sun.xml.internal.ws.model.CheckedExceptionImpl;
import com.sun.xml.internal.ws.model.JavaMethodImpl;
import com.sun.xml.internal.ws.spi.db.XMLBridge;
import com.sun.xml.internal.ws.util.DOMUtil;
import com.sun.xml.internal.ws.util.StringUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPFault;
import javax.xml.soap.Detail;
import javax.xml.soap.DetailEntry;
import javax.xml.transform.dom.DOMResult;
import javax.xml.ws.ProtocolException;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.soap.SOAPFaultException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.ReflectPermission;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.Permissions;
import java.security.PrivilegedAction;
import java.security.ProtectionDomain;
import java.util.Iterator;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Base class that represents SOAP 1.1 or SOAP 1.2 fault. This class can be used by the invocation handlers to create
* an Exception from a received messge.
*
* @author Vivek Pandey
*/
public abstract class SOAPFaultBuilder {
/**
* Gives the {@link DetailType} for a Soap 1.1 or Soap 1.2 message that can be used to create either a checked exception or
* a protocol specific exception
*/
abstract DetailType getDetail();
abstract void setDetail(DetailType detailType);
public @XmlTransient @Nullable QName getFirstDetailEntryName() {
DetailType dt = getDetail();
if (dt != null) {
Node entry = dt.getDetail(0);
if (entry != null) {
return new QName(entry.getNamespaceURI(), entry.getLocalName());
}
}
return null;
}
/**
* gives the fault string that can be used to create an {@link Exception}
*/
abstract String getFaultString();
/**
* This should be called from the client side to throw an {@link Exception} for a given soap mesage
*/
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
DetailType dt = getDetail();
Node detail = null;
if(dt != null) detail = dt.getDetail(0);
//return ProtocolException if the detail is not present or there is no checked exception
if(detail == null || exceptions == null){
// No soap detail, doesnt look like its a checked exception
// throw a protocol exception
return attachServerException(getProtocolException());
}
//check if the detail is a checked exception, if not throw a ProtocolException
QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
CheckedExceptionImpl ce = exceptions.get(detailName);
if (ce == null) {
//No Checked exception for the received detail QName, throw a SOAPFault exception
return attachServerException(getProtocolException());
}
if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
return attachServerException(createUserDefinedException(ce));
}
Class exceptionClass = ce.getExceptionClass();
try {
Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
return attachServerException(exception);
} catch (Exception e) {
throw new WebServiceException(e);
}
}
/**
* To be called to convert a {@link ProtocolException} and faultcode for a given {@link SOAPVersion} in to a {@link Message}.
*
* @param soapVersion {@link SOAPVersion#SOAP_11} or {@link SOAPVersion#SOAP_12}
* @param ex a ProtocolException
* @param faultcode soap faultcode. Its ignored if the {@link ProtocolException} instance is {@link SOAPFaultException} and it has a
* faultcode present in the underlying {@link SOAPFault}.
* @return {@link Message} representing SOAP fault
*/
public static @NotNull Message createSOAPFaultMessage(@NotNull SOAPVersion soapVersion, @NotNull ProtocolException ex, @Nullable QName faultcode){
Object detail = getFaultDetail(null, ex);
if(soapVersion == SOAPVersion.SOAP_12)
return createSOAP12Fault(soapVersion, ex, detail, null, faultcode);
return createSOAP11Fault(soapVersion, ex, detail, null, faultcode);
}
/**
* To be called by the server runtime in the situations when there is an Exception that needs to be transformed in
* to a soapenv:Fault payload.
*
* @param ceModel {@link CheckedExceptionImpl} model that provides useful informations such as the detail tagname
* and the Exception associated with it. Caller of this constructor should get the CheckedException
* model by calling {@link JavaMethodImpl#getCheckedException(Class)}, where
* Class is t.getClass().
* <p>
* If its null then this is not a checked exception and in that case the soap fault will be
* serialized only from the exception as described below.
* @param ex Exception that needs to be translated into soapenv:Fault, always non-null.
* <ul>
* <li>If t is instance of {@link SOAPFaultException} then its serilaized as protocol exception.
* <li>If t.getCause() is instance of {@link SOAPFaultException} and t is a checked exception then
* the soap fault detail is serilaized from t and the fault actor/string/role is taken from t.getCause().
* </ul>
* @param soapVersion non-null
*/
public static Message createSOAPFaultMessage(SOAPVersion soapVersion, CheckedExceptionImpl ceModel, Throwable ex) {
// Sometimes InvocationTargetException.getCause() is null
// but InvocationTargetException.getTargetException() contains the real exception
// even though they are supposed to be equivalent.
// If we only look at .getCause this results in the real exception being lost.
// Looks like a JDK bug.
final Throwable t =
ex instanceof java.lang.reflect.InvocationTargetException
?
((java.lang.reflect.InvocationTargetException)ex).getTargetException()
:
ex;
return createSOAPFaultMessage(soapVersion, ceModel, t, null);
}
/**
* Create the Message with the specified faultCode
*
* @see #createSOAPFaultMessage(SOAPVersion, CheckedExceptionImpl, Throwable)
*/
public static Message createSOAPFaultMessage(SOAPVersion soapVersion, CheckedExceptionImpl ceModel, Throwable ex, QName faultCode) {
Object detail = getFaultDetail(ceModel, ex);
if(soapVersion == SOAPVersion.SOAP_12)
return createSOAP12Fault(soapVersion, ex, detail, ceModel, faultCode);
return createSOAP11Fault(soapVersion, ex, detail, ceModel, faultCode);
}
/**
* Server runtime will call this when there is some internal error not resulting from an exception.
*
* @param soapVersion {@link SOAPVersion#SOAP_11} or {@link SOAPVersion#SOAP_12}
* @param faultString must be non-null
* @param faultCode For SOAP 1.1, it must be one of
* <ul>
* <li>{@link SOAPVersion#faultCodeClient}
* <li>{@link SOAPVersion#faultCodeServer}
* <li>{@link SOAPConstants#FAULT_CODE_MUST_UNDERSTAND}
* <li>{@link SOAPConstants#FAULT_CODE_VERSION_MISMATCH}
* </ul>
*
* For SOAP 1.2
* <ul>
* <li>{@link SOAPVersion#faultCodeClient}
* <li>{@link SOAPVersion#faultCodeServer}
* <li>{@link SOAP12Constants#FAULT_CODE_MUST_UNDERSTAND}
* <li>{@link SOAP12Constants#FAULT_CODE_VERSION_MISMATCH}
* <li>{@link SOAP12Constants#FAULT_CODE_DATA_ENCODING_UNKNOWN}
* </ul>
* @return non-null {@link Message}
*/
public static Message createSOAPFaultMessage(SOAPVersion soapVersion, String faultString, QName faultCode) {
if (faultCode == null)
faultCode = getDefaultFaultCode(soapVersion);
return createSOAPFaultMessage(soapVersion, faultString, faultCode, null);
}
public static Message createSOAPFaultMessage(SOAPVersion soapVersion, SOAPFault fault) {
switch (soapVersion) {
case SOAP_11:
return JAXBMessage.create(JAXB_CONTEXT, new SOAP11Fault(fault), soapVersion);
case SOAP_12:
return JAXBMessage.create(JAXB_CONTEXT, new SOAP12Fault(fault), soapVersion);
default:
throw new AssertionError();
}
}
private static Message createSOAPFaultMessage(SOAPVersion soapVersion, String faultString, QName faultCode, Element detail) {
switch (soapVersion) {
case SOAP_11:
return JAXBMessage.create(JAXB_CONTEXT, new SOAP11Fault(faultCode, faultString, null, detail), soapVersion);
case SOAP_12:
return JAXBMessage.create(JAXB_CONTEXT, new SOAP12Fault(faultCode, faultString, detail), soapVersion);
default:
throw new AssertionError();
}
}
/**
* Creates a DOM node that represents the complete stack trace of the exception,
* and attach that to {@link DetailType}.
*/
final void captureStackTrace(@Nullable Throwable t) {
if(t==null) return;
if(!captureStackTrace) return; // feature disabled
try {
Document d = DOMUtil.createDom();
ExceptionBean.marshal(t,d);
DetailType detail = getDetail();
if(detail==null)
setDetail(detail=new DetailType());
detail.getDetails().add(d.getDocumentElement());
} catch (JAXBException e) {
// this should never happen
logger.log(Level.WARNING, "Unable to capture the stack trace into XML",e);
}
}
/**
* Initialize the cause of this exception by attaching the server side exception.
*/
private <T extends Throwable> T attachServerException(T t) {
DetailType detail = getDetail();
if(detail==null) return t; // no details
for (Element n : detail.getDetails()) {
if(ExceptionBean.isStackTraceXml(n)) {
try {
t.initCause(ExceptionBean.unmarshal(n));
} catch (JAXBException e) {
// perhaps incorrectly formatted XML.
logger.log(Level.WARNING, "Unable to read the capture stack trace in the fault",e);
}
return t;
}
}
return t;
}
abstract protected Throwable getProtocolException();
private Object getJAXBObject(Node jaxbBean, CheckedExceptionImpl ce) throws JAXBException {
XMLBridge bridge = ce.getBond();
return bridge.unmarshal(jaxbBean,null);
}
private Exception createUserDefinedException(CheckedExceptionImpl ce) {
Class exceptionClass = ce.getExceptionClass();
Class detailBean = ce.getDetailBean();
try{
Node detailNode = getDetail().getDetails().get(0);
Object jaxbDetail = getJAXBObject(detailNode, ce);
Constructor exConstructor;
try{
exConstructor = exceptionClass.getConstructor(String.class, detailBean);
return (Exception) exConstructor.newInstance(getFaultString(), jaxbDetail);
}catch(NoSuchMethodException e){
exConstructor = exceptionClass.getConstructor(String.class);
return (Exception) exConstructor.newInstance(getFaultString());
}
} catch (Exception e) {
throw new WebServiceException(e);
}
}
private static String getWriteMethod(Field f) {
return "set" + StringUtils.capitalize(f.getName());
}
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
if (ce == null)
return null;
if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
return createDetailFromUserDefinedException(ce, exception);
}
try {
Method m = exception.getClass().getMethod("getFaultInfo");
return m.invoke(exception);
} catch (Exception e) {
throw new SerializationException(e);
}
}
private static Object createDetailFromUserDefinedException(CheckedExceptionImpl ce, Object exception) {
Class detailBean = ce.getDetailBean();
Field[] fields = detailBean.getDeclaredFields();
try {
Object detail = detailBean.newInstance();
for (Field f : fields) {
Method em = exception.getClass().getMethod(getReadMethod(f));
try {
Method sm = detailBean.getMethod(getWriteMethod(f), em.getReturnType());
sm.invoke(detail, em.invoke(exception));
} catch(NoSuchMethodException ne) {
// Try to use exception bean's public field to populate the value.
Field sf = detailBean.getField(f.getName());
sf.set(detail, em.invoke(exception));
}
}
return detail;
} catch (Exception e) {
throw new SerializationException(e);
}
}
private static String getReadMethod(Field f) {
if (f.getType().isAssignableFrom(boolean.class))
return "is" + StringUtils.capitalize(f.getName());
return "get" + StringUtils.capitalize(f.getName());
}
private static Message createSOAP11Fault(SOAPVersion soapVersion, Throwable e, Object detail, CheckedExceptionImpl ce, QName faultCode) {
SOAPFaultException soapFaultException = null;
String faultString = null;
String faultActor = null;
Throwable cause = e.getCause();
if (e instanceof SOAPFaultException) {
soapFaultException = (SOAPFaultException) e;
} else if (cause != null && cause instanceof SOAPFaultException) {
soapFaultException = (SOAPFaultException) e.getCause();
}
if (soapFaultException != null) {
QName soapFaultCode = soapFaultException.getFault().getFaultCodeAsQName();
if(soapFaultCode != null)
faultCode = soapFaultCode;
faultString = soapFaultException.getFault().getFaultString();
faultActor = soapFaultException.getFault().getFaultActor();
}
if (faultCode == null) {
faultCode = getDefaultFaultCode(soapVersion);
}
if (faultString == null) {
faultString = e.getMessage();
if (faultString == null) {
faultString = e.toString();
}
}
Element detailNode = null;
QName firstEntry = null;
if (detail == null && soapFaultException != null) {
detailNode = soapFaultException.getFault().getDetail();
firstEntry = getFirstDetailEntryName((Detail)detailNode);
} else if(ce != null){
try {
DOMResult dr = new DOMResult();
ce.getBond().marshal(detail,dr);
detailNode = (Element)dr.getNode().getFirstChild();
firstEntry = getFirstDetailEntryName(detailNode);
} catch (JAXBException e1) {
//Should we throw Internal Server Error???
faultString = e.getMessage();
faultCode = getDefaultFaultCode(soapVersion);
}
}
SOAP11Fault soap11Fault = new SOAP11Fault(faultCode, faultString, faultActor, detailNode);
//Don't fill the stacktrace for Service specific exceptions.
if(ce == null) {
soap11Fault.captureStackTrace(e);
}
Message msg = JAXBMessage.create(JAXB_CONTEXT, soap11Fault, soapVersion);
return new FaultMessage(msg, firstEntry);
}
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
if (detail != null) {
Iterator<DetailEntry> it = detail.getDetailEntries();
if (it.hasNext()) {
DetailEntry entry = it.next();
return getFirstDetailEntryName(entry);
}
}
return null;
}
private static @NotNull QName getFirstDetailEntryName(@NotNull Element entry) {
return new QName(entry.getNamespaceURI(), entry.getLocalName());
}
private static Message createSOAP12Fault(SOAPVersion soapVersion, Throwable e, Object detail, CheckedExceptionImpl ce, QName faultCode) {
SOAPFaultException soapFaultException = null;
CodeType code = null;
String faultString = null;
String faultRole = null;
String faultNode = null;
Throwable cause = e.getCause();
if (e instanceof SOAPFaultException) {
soapFaultException = (SOAPFaultException) e;
} else if (cause != null && cause instanceof SOAPFaultException) {
soapFaultException = (SOAPFaultException) e.getCause();
}
if (soapFaultException != null) {
SOAPFault fault = soapFaultException.getFault();
QName soapFaultCode = fault.getFaultCodeAsQName();
if(soapFaultCode != null){
faultCode = soapFaultCode;
code = new CodeType(faultCode);
Iterator iter = fault.getFaultSubcodes();
boolean first = true;
SubcodeType subcode = null;
while(iter.hasNext()){
QName value = (QName)iter.next();
if(first){
SubcodeType sct = new SubcodeType(value);
code.setSubcode(sct);
subcode = sct;
first = false;
continue;
}
subcode = fillSubcodes(subcode, value);
}
}
faultString = soapFaultException.getFault().getFaultString();
faultRole = soapFaultException.getFault().getFaultActor();
faultNode = soapFaultException.getFault().getFaultNode();
}
if (faultCode == null) {
faultCode = getDefaultFaultCode(soapVersion);
code = new CodeType(faultCode);
}else if(code == null){
code = new CodeType(faultCode);
}
if (faultString == null) {
faultString = e.getMessage();
if (faultString == null) {
faultString = e.toString();
}
}
ReasonType reason = new ReasonType(faultString);
Element detailNode = null;
QName firstEntry = null;
if (detail == null && soapFaultException != null) {
detailNode = soapFaultException.getFault().getDetail();
firstEntry = getFirstDetailEntryName((Detail)detailNode);
} else if(detail != null){
try {
DOMResult dr = new DOMResult();
ce.getBond().marshal(detail, dr);
detailNode = (Element)dr.getNode().getFirstChild();
firstEntry = getFirstDetailEntryName(detailNode);
} catch (JAXBException e1) {
//Should we throw Internal Server Error???
faultString = e.getMessage();
}
}
SOAP12Fault soap12Fault = new SOAP12Fault(code, reason, faultNode, faultRole, detailNode);
//Don't fill the stacktrace for Service specific exceptions.
if(ce == null) {
soap12Fault.captureStackTrace(e);
}
Message msg = JAXBMessage.create(JAXB_CONTEXT, soap12Fault, soapVersion);
return new FaultMessage(msg, firstEntry);
}
private static SubcodeType fillSubcodes(SubcodeType parent, QName value){
SubcodeType newCode = new SubcodeType(value);
parent.setSubcode(newCode);
return newCode;
}
private static QName getDefaultFaultCode(SOAPVersion soapVersion) {
return soapVersion.faultCodeServer;
}
/**
* Parses a fault {@link Message} and returns it as a {@link SOAPFaultBuilder}.
*
* @return always non-null valid object.
* @throws JAXBException if the parsing fails.
*/
public static SOAPFaultBuilder create(Message msg) throws JAXBException {
return msg.readPayloadAsJAXB(JAXB_CONTEXT.createUnmarshaller());
}
/**
* This {@link JAXBContext} can handle SOAP 1.1/1.2 faults.
*/
private static final JAXBContext JAXB_CONTEXT;
private static final Logger logger = Logger.getLogger(SOAPFaultBuilder.class.getName());
/**
* Set to false if you don't want the generated faults to have stack trace in it.
*/
public static final boolean captureStackTrace;
/*package*/ static final String CAPTURE_STACK_TRACE_PROPERTY = SOAPFaultBuilder.class.getName()+".captureStackTrace";
static {
boolean tmpVal = false;
try {
tmpVal = Boolean.getBoolean(CAPTURE_STACK_TRACE_PROPERTY);
} catch (SecurityException e) {
// ignore
}
captureStackTrace = tmpVal;
JAXB_CONTEXT = createJAXBContext();
}
private static JAXBContext createJAXBContext() {
// in jdk runtime doPrivileged is necessary since JAX-WS internal classes are in restricted packages
if (isJDKRuntime()) {
Permissions permissions = new Permissions();
permissions.add(new RuntimePermission("accessClassInPackage.com.sun." + "xml.internal.ws.fault"));
permissions.add(new ReflectPermission("suppressAccessChecks"));
return AccessController.doPrivileged(
new PrivilegedAction<JAXBContext>() {
@Override
public JAXBContext run() {
try {
return JAXBContext.newInstance(SOAP11Fault.class, SOAP12Fault.class);
} catch (JAXBException e) {
throw new Error(e);
}
}
},
new AccessControlContext(new ProtectionDomain[]{new ProtectionDomain(null, permissions)})
);
} else {
try {
return JAXBContext.newInstance(SOAP11Fault.class, SOAP12Fault.class);
} catch (JAXBException e) {
throw new Error(e);
}
}
}
private static boolean isJDKRuntime() {
return SOAPFaultBuilder.class.getName().contains("internal");
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.fault;
import javax.xml.soap.SOAPFault;
import javax.xml.ws.soap.SOAPFaultException;
/**
* Represents the SOAPFaultException that has occurred on the server side.
*
* <p>
* When an exception occurs on the server, JAX-WS RI sends the SOAPFaultException
* to the client. On the client side, instances of this class are used to represent
* SOAPFaultException that adds diagnostic information to error message for easily
* identifying the cause of exception.
*
* @author chinmay.patel
*
*/
public class ServerSOAPFaultException extends SOAPFaultException {
public ServerSOAPFaultException(SOAPFault soapFault) {
super(soapFault);
}
public String getMessage() {
return "Client received SOAP Fault from server: "
+ super.getMessage()
+ " Please see the server log to find more detail regarding exact cause of the failure.";
}
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.fault;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.namespace.QName;
/**
* <pre>
* &lt;env:Subcode>
* &lt;env:Value>m:MessageTimeout1&lt;/env:Value>
* &lt;env:Subcode>
* &lt;env:Value>m:MessageTimeout2&lt;/env:Value>
* &lt;/env:Subcode>
* &lt;/env:Subcode>
* </pre>
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SubcodeType", namespace = "http://www.w3.org/2003/05/soap-envelope", propOrder = {
"Value",
"Subcode"
})
class SubcodeType {
@XmlTransient
private static final String ns="http://www.w3.org/2003/05/soap-envelope";
/**
* mandatory, minOccurs=1
*/
@XmlElement(namespace = ns)
private QName Value;
/**
* optional, minOcccurs=0
*/
@XmlElements(@XmlElement(namespace = ns))
private SubcodeType Subcode;
public SubcodeType(QName value) {
Value = value;
}
public SubcodeType() {
}
QName getValue() {
return Value;
}
SubcodeType getSubcode() {
return Subcode;
}
void setSubcode(SubcodeType subcode) {
Subcode = subcode;
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.fault;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;
import javax.xml.bind.annotation.XmlAttribute;
import java.util.Locale;
/**
* <pre>
* &lt;env:Text xml:lang="en">Sender Timeout</env:Text>
* </pre>
*/
@XmlType(name = "TextType", namespace = "http://www.w3.org/2003/05/soap-envelope")
class TextType {
private @XmlValue String text;
/**
* xml:lang attribute. What should be value of namespace for "xml"
*/
@XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace", required = true)
private String lang;
TextType() {
}
TextType(String text) {
this.text = text;
this.lang = Locale.getDefault().getLanguage();
}
String getText(){
return text;
}
}