當前位置: 首頁>>代碼示例>>Java>>正文


Java SOAPFault.addFaultReasonText方法代碼示例

本文整理匯總了Java中javax.xml.soap.SOAPFault.addFaultReasonText方法的典型用法代碼示例。如果您正苦於以下問題:Java SOAPFault.addFaultReasonText方法的具體用法?Java SOAPFault.addFaultReasonText怎麽用?Java SOAPFault.addFaultReasonText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.soap.SOAPFault的用法示例。


在下文中一共展示了SOAPFault.addFaultReasonText方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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);
   }
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:22,代碼來源:JBWS3945EndpointImpl.java

示例2: 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);
   }
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:20,代碼來源:SOAP12EndpointImpl.java

示例3: createFault

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
/**
 * Creates a new SOAPFault object initialized with the given reasonText and faultCode
 *
 * @param reasonText - the ReasonText/FaultString for the fault faultCode - the FaultCode for
 *                   the fault
 * @return: a SOAPFault object
 * @throws: SOAPException - if there is a SOAP error
 */
public SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException {
    SOAPFault soapFault;
    if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
        soapFault = new SOAPFaultImpl(DOOMAbstractFactory.getSOAP12Factory()
                .createSOAPFault());
    } else {
        soapFault = new SOAPFaultImpl(DOOMAbstractFactory.getSOAP11Factory()
                .createSOAPFault());
    }
    soapFault.setFaultCode(faultCode);
    try {
        soapFault.addFaultReasonText(reasonText, Locale.getDefault());
    } catch (UnsupportedOperationException e) {
        throw new SOAPException(e.getMessage());
    }

    return soapFault;
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:27,代碼來源:SOAPFactoryImpl.java

示例4: _testGetFaultReasonTexts

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public void _testGetFaultReasonTexts() throws Exception {
    MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);

    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("cwmp", "http://cwmp.com");
    SOAPBody body = envelope.getBody();
    SOAPFault soapFault = body.addFault();
    soapFault.addFaultReasonText("myReason", new Locale("en"));
    soapFault.addFaultReasonText("de-myReason", new Locale("de"));
    soapFault.addFaultReasonText("si-myReason", new Locale("si"));
    soapMessage.saveChanges();
    Iterator reasonTexts = soapFault.getFaultReasonTexts();
    while (reasonTexts.hasNext()) {
        String reasonText = (String)reasonTexts.next();
        assertNotNull(reasonText);
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:21,代碼來源:SOAPFaultTest.java

示例5: _testGetFaultReasonText

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public void _testGetFaultReasonText() throws Exception {
    MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);

    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("cwmp", "http://cwmp.com");
    SOAPBody body = envelope.getBody();
    SOAPFault soapFault = body.addFault();
    soapFault.addFaultReasonText("myReason", new Locale("en"));
    soapFault.addFaultReasonText("de-myReason", new Locale("de"));
    soapFault.addFaultReasonText("si-myReason", new Locale("si"));
    soapMessage.saveChanges();

    String faultReasonText = soapFault.getFaultReasonText(new Locale("si"));
    assertNotNull(faultReasonText);
    faultReasonText = soapFault.getFaultReasonText(new Locale("ja"));
    assertNull(faultReasonText);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:21,代碼來源:SOAPFaultTest.java

示例6: _testGetFaultCodeAsQName

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public void _testGetFaultCodeAsQName() throws Exception {
    //MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    MessageFactory fac = MessageFactory.newInstance();

    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("cwmp", "http://cwmp.com");
    SOAPBody body = envelope.getBody();
    SOAPFault soapFault = body.addFault();
    soapFault.addFaultReasonText("myReason", new Locale("en"));
    soapFault.setFaultCode("mycode");
    soapMessage.saveChanges();

    QName qname = soapFault.getFaultCodeAsQName();
    assertNotNull(qname);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:19,代碼來源:SOAPFaultTest.java

示例7: _testAddFaultReasonText1

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public void _testAddFaultReasonText1() throws Exception {
    MessageFactory fac = MessageFactory.newInstance();
    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("cwmp", "http://cwmp.com");
    SOAPBody body = envelope.getBody();
    SOAPFault soapFault = body.addFault();
    soapFault.addFaultReasonText("myReason", Locale.ENGLISH);
    soapMessage.saveChanges();
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:13,代碼來源:SOAPFaultTest.java

示例8: testAddFaultReasonText2

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Validated @Test
public void testAddFaultReasonText2() throws Exception {
    MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("cwmp", "http://cwmp.com");
    SOAPBody body = envelope.getBody();
    SOAPFault soapFault = body.addFault();
    soapFault.addFaultReasonText("myReason", new Locale("en"));
    soapFault.addFaultReasonText("de-myReason", new Locale("de"));
    soapFault.addFaultReasonText("si-myReason", new Locale("si"));
    soapMessage.saveChanges();
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:16,代碼來源:SOAPFaultTest.java

示例9: testAddFaultReasonText3

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Validated @Test
public void testAddFaultReasonText3() throws Exception {
    MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

    SOAPEnvelope envelope = soapPart.getEnvelope();
    SOAPBody body = envelope.getBody();
    SOAPFault sf = body.addFault();
    
    String expected = "Its my fault again";
    boolean found = false;
    sf.addFaultReasonText("Its my fault", Locale.ENGLISH);
    sf.addFaultReasonText(expected, Locale.ENGLISH);
    Iterator i = sf.getFaultReasonTexts();
    int j = 0;
    while (i.hasNext()) {
        Object o = i.next();
        if (o != null && o instanceof String) {
            String actual = (String)o;
            if (actual.equals(expected)) {
                if (!found) {
                    found = true;
                }
            }
        }
        j++;
    }
    if (j < 1) {
        fail("No reason text was returned");
    }
    if (j > 1) {
        fail("More than one reason text was returned");
    }
    if (!found) {
        fail("The following Reason text was not received: '" + expected + "'");
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:39,代碼來源:SOAPFaultTest.java

示例10: testAddFaultReasonText4

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Validated @Test
public void testAddFaultReasonText4() throws Exception {
    MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();
    SOAPEnvelope envelope = soapPart.getEnvelope();
    SOAPBody body = envelope.getBody();
    SOAPFault sf = body.addFault();
    
    String expected1 = "Its my fault";
    String expected2 = "Its my fault again";

    boolean found1 = false;
    boolean found2 = false;
    sf.addFaultReasonText(expected1, Locale.UK);
    sf.addFaultReasonText(expected2, Locale.ENGLISH);
    Iterator i = sf.getFaultReasonTexts();
    int j = 0;
    while (i.hasNext()) {
        Object o = i.next();
        if (o != null && o instanceof String) {
            String actual = (String)o;
            if (actual.equals(expected1)) {
                if (!found1) {
                    found1 = true;
                }
            } else if (actual.equals(expected2)) {
                if (!found2) {
                    found2 = true;
                }
            }
        }
        j++;
    }
    if (j < 1) {
        fail("No reason text was returned");
    }
    if (j > 2) {
        fail("More than two reason texts were returned");
    }
    if (!found1) {
        fail("The following Reason text was not received: '" + expected1 + "'");
    }
    if (!found2) {
        fail("The following Reason text was not received: '" + expected2 + "'");
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:48,代碼來源:SOAPFaultTest.java

示例11: testFaultReasonLocales

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Validated @Test
public void testFaultReasonLocales() throws Exception  {
    MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();
    SOAPEnvelope envelope = soapPart.getEnvelope();
    SOAPBody body = envelope.getBody();
    //SOAPFault sf = body.addFault();
    
    Locale expected1 = Locale.ENGLISH;
    Locale expected2 = Locale.UK;
    Locale expected3 = Locale.GERMAN;
    boolean found1 = false;
    boolean found2 = false;
    boolean found3 = false;

    SOAPFault sf = body.addFault(SOAPConstants.SOAP_RECEIVER_FAULT, "Its my fault1", expected1);
    sf.addFaultReasonText("Its my fault1", expected1);
    sf.addFaultReasonText("Its my fault2", expected2);
    sf.addFaultReasonText("Its my fault3", expected3);
    Iterator i = sf.getFaultReasonLocales();

    int localeCount = 0;
    while (i.hasNext()) {
        localeCount++;
        i.next();
    }

    i = sf.getFaultReasonLocales();
    int j = 0;
    while (i.hasNext()) {
        Object o = i.next();
        if (o instanceof Locale) {
            Locale actual = (Locale)o;
            if (actual != null) {
                if (actual.equals(expected1)) {
                    if (!found1) {
                        found1 = true;
                    }
                } else if (actual.equals(expected2)) {
                    if (!found2) {
                        found2 = true;
                    }
                } else if (actual.equals(expected3)) {
                    if (!found3) {
                        found3 = true;
                    }
                }
            }
        }
        j++;
    }
    if (j < 1) {
        fail("No reason text was returned");
    }
    if (j > 3) {
        fail("More than 3 Locales were returned");
    }
    if (!found1) {
        fail("The following Locale was not received: '" + expected1 + "'");
    }
    if (!found2) {
        fail("The following Locale was not received: '" + expected2 + "'");
    }
    if (!found3) {
        fail("The following Locale was not received: '" + expected3 + "'");
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:69,代碼來源:SOAPFaultTest.java


注:本文中的javax.xml.soap.SOAPFault.addFaultReasonText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。