本文整理匯總了Java中javax.xml.soap.SOAPFault.setFaultActor方法的典型用法代碼示例。如果您正苦於以下問題:Java SOAPFault.setFaultActor方法的具體用法?Java SOAPFault.setFaultActor怎麽用?Java SOAPFault.setFaultActor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.soap.SOAPFault
的用法示例。
在下文中一共展示了SOAPFault.setFaultActor方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getProtocolException
import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
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);
}
}
示例2: addFault
import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
/**
* Adds a SOAP fault to the SOAP message of this response.
*
* @param code the fault code.
* @param actor the fault actor.
* @param desc the fault description.
* @return the SOAP fault which has been added to the SOAP message. null if
* there is no SOAP message in this response or the fault has
* already been added.
* @throws SOAPException a SOAP error occurred when adding the the fault.
*/
public SOAPFault addFault(String code, String actor, String desc)
throws SOAPException {
SOAPMessage msg = getMessage();
if (msg != null) {
SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
SOAPBody body = env.getBody();
if (body != null && !body.hasFault()) {
SOAPFault fault = body.addFault();
if (code != null) {
fault.setFaultCode(env.getElementName().getPrefix() + ":"
+ code);
}
if (actor != null) {
fault.setFaultActor(actor);
}
if (desc != null) {
fault.setFaultString(desc);
}
return fault;
}
}
return null;
}
示例3: throwSoapFaultException
import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public void throwSoapFaultException()
{
// This should be thrown as-is
try
{
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault fault = factory.createFault("this is a fault string!", SOAPConstants.SOAP_VERSIONMISMATCH_FAULT);
fault.setFaultActor("mr.actor");
fault.addDetail().addChildElement("test");
throw new SOAPFaultException(fault);
}
catch (SOAPException s)
{
throw new RuntimeException(s);
}
}
示例4: throwSoapFaultException
import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public void throwSoapFaultException()
{
try
{
MessageContext ctx = context.getMessageContext();
ctx.put(MessageContext.HTTP_RESPONSE_CODE, 400);
SOAPFactory factory = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPFault fault = factory.createFault();
fault.addFaultReasonText("this is a fault string!", Locale.ITALIAN);
fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
fault.setFaultActor("mr.actor");
fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "AnException"));
fault.addDetail().addChildElement("test");
throw new SOAPFaultException(fault);
}
catch (Exception s)
{
throw new RuntimeException(s);
}
}
示例5: throwSoapFaultException
import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public void throwSoapFaultException()
{
// This should be thrown as-is
try
{
SOAPFactory factory = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPFault fault = factory.createFault();
fault.addFaultReasonText("this is a fault string!", Locale.ITALIAN);
fault.setFaultCode(SOAPConstants.SOAP_VERSIONMISMATCH_FAULT);
fault.setFaultActor("mr.actor");
fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "NullPointerException"));
fault.addDetail().addChildElement("test");
throw new SOAPFaultException(fault);
}
catch (SOAPException s)
{
throw new RuntimeException(s);
}
}
示例6: getProtocolException
import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
protected Throwable getProtocolException() {
try {
SOAPFault fault = SOAPVersion.SOAP_11.saajSoapFactory.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 SOAPFaultException(fault);
} catch (SOAPException e) {
throw new WebServiceException(e);
}
}
示例7: throwSoapFaultException
import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public void throwSoapFaultException()
{
// This should be thrown as-is
try
{
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault fault = factory.createFault("this is a fault string!", new QName("http://foo", "FooCode"));
fault.setFaultActor("mr.actor");
fault.addDetail().addChildElement("test");
throw new SOAPFaultException(fault);
}
catch (SOAPException s)
{
throw new RuntimeException(s);
}
}
示例8: getSOAPMessage
import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
/**
* Get SOAP Fault message from the information given.
*
* @return <code>SOAPMessage</code> object containing Fault element.
*/
public SOAPMessage getSOAPMessage() {
try {
final MessageFactory mf = MessageFactory.newInstance();
final SOAPMessage message = (SOAPMessage)mf.createMessage();
// set default SOAP XML declaration and encoding
message.setProperty(SOAPMessage.WRITE_XML_DECLARATION,
Boolean.toString(EbxmlMessage.WRITE_XML_DECLARATION));
message.setProperty(SOAPMessage.CHARACTER_SET_ENCODING,
EbxmlMessage.CHARACTER_SET_ENCODING);
final SOAPPart part = message.getSOAPPart();
final SOAPEnvelope envelope = part.getEnvelope();
final SOAPBody body = envelope.getBody();
final SOAPFault fault = body.addFault();
fault.setFaultCode(errorCode);
fault.setFaultString(errorString);
if (faultActor != null) {
fault.setFaultActor(faultActor);
}
if (detail != null) {
Detail d = fault.addDetail();
Name name = envelope.createName(ELEMENT_ERROR,
NAMESPACE_PREFIX_CECID, NAMESPACE_URI_CECID);
DetailEntry entry = d.addDetailEntry(name);
entry.addTextNode(detail);
}
return message;
}
catch (SOAPException e) {
}
return null;
}
示例9: testGetFaultActor
import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Validated @Test
public void testGetFaultActor() throws Exception {
SOAPMessage msg = MessageFactory.newInstance().createMessage();
SOAPFault sf = msg.getSOAPBody().addFault();
sf.setFaultActor("/faultActorURI");
sf.setFaultActor("/faultActorURI2");
String result = sf.getFaultActor();
if (!result.equals("/faultActorURI2")) {
fail("Fault Actor not properly set");
}
}
示例10: testFaults
import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Validated @Test
public void testFaults() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPFactory soapFactory = SOAPFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
SOAPBody body = message.getSOAPBody();
SOAPFault fault = body.addFault();
Name faultName =
soapFactory.createName("Client", "",
SOAPConstants.URI_NS_SOAP_ENVELOPE);
fault.setFaultCode(faultName);
fault.setFaultString("Message does not have necessary info");
fault.setFaultActor("http://gizmos.com/order");
Detail detail = fault.addDetail();
Name entryName =
soapFactory.createName("order", "PO",
"http://gizmos.com/orders/");
DetailEntry entry = detail.addDetailEntry(entryName);
entry.addTextNode("Quantity element does not have a value");
Name entryName2 =
soapFactory.createName("confirmation", "PO",
"http://gizmos.com/confirm");
DetailEntry entry2 = detail.addDetailEntry(entryName2);
entry2.addTextNode("Incomplete address: " + "no zip code");
message.saveChanges();
//message.writeTo(System.out);
// Now retrieve the SOAPFault object and
// its contents, after checking to see that
// there is one
if (body.hasFault()) {
SOAPFault newFault = body.getFault();
// Get the qualified name of the fault code
assertNotNull(newFault.getFaultCodeAsName());
assertNotNull(newFault.getFaultString());
assertNotNull(newFault.getFaultActor());
Detail newDetail = newFault.getDetail();
if (newDetail != null) {
Iterator entries = newDetail.getDetailEntries();
while (entries.hasNext()) {
DetailEntry newEntry = (DetailEntry)entries.next();
String value = newEntry.getValue();
assertNotNull(value);
}
}
}
}