当前位置: 首页>>代码示例>>Java>>正文


Java SOAPFault类代码示例

本文整理汇总了Java中javax.xml.soap.SOAPFault的典型用法代码示例。如果您正苦于以下问题:Java SOAPFault类的具体用法?Java SOAPFault怎么用?Java SOAPFault使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SOAPFault类属于javax.xml.soap包,在下文中一共展示了SOAPFault类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: callWebService

import javax.xml.soap.SOAPFault; //导入依赖的package包/类
public void callWebService(String iccid, String businessValue) throws SOAPException, IOException, XWSSecurityException, Exception {
    SOAPMessage request = createTerminalRequest(iccid, businessValue);
    request = secureMessage(request);

    // TODO
    logger.info("Edit Terminal Request: ");
    request.writeTo(System.out);
    System.out.println("");

    SOAPConnection connection = connectionFactory.createConnection();
    SOAPMessage response = connection.call(request, url);
    // TODO
    logger.info("Edit Terminal Response: ");
    response.writeTo(System.out);
    System.out.println("");

    if (!response.getSOAPBody().hasFault()) {
        writeTerminalResponse(response);
    } else {
        SOAPFault fault = response.getSOAPBody().getFault();
        logger.error("Received SOAP Fault");
        logger.error("SOAP Fault Code :" + fault.getFaultCode());
        logger.error("SOAP Fault String :" + fault.getFaultString());
    }
}
 
开发者ID:booleguo,项目名称:sam-elle,代码行数:26,代码来源:EditTerminalClient.java

示例2: SOAP12Fault

import javax.xml.soap.SOAPFault; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:SOAP12Fault.java

示例3: callWebService

import javax.xml.soap.SOAPFault; //导入依赖的package包/类
public String callWebService(String msisdn) throws SOAPException, IOException, XWSSecurityException, GetTermalIccidException {
    SOAPMessage request = createTerminalRequest(msisdn);
    request = secureMessage(request);

    // TODO
    logger.info("Get Terminals by msisdn Request: ");
    request.writeTo(System.out);
    System.out.println("");

    SOAPConnection connection = connectionFactory.createConnection();
    SOAPMessage response = connection.call(request, url);
    // TODO
    logger.info("Get Terminals by msisdn Response: ");
    response.writeTo(System.out);
    System.out.println("");

    if (!response.getSOAPBody().hasFault()) {
        return writeTerminalResponse(response);
    } else {
        SOAPFault fault = response.getSOAPBody().getFault();
        logger.error("Received SOAP Fault");
        logger.error("SOAP Fault Code :" + fault.getFaultCode());
        logger.error("SOAP Fault String :" + fault.getFaultString());
        throw new GetTermalIccidException(fault.getFaultCode() + "," + fault.getFaultString());
    }
}
 
开发者ID:booleguo,项目名称:sam-elle,代码行数:27,代码来源:GetTerminalsByMsisdnClient.java

示例4: _testQuick

import javax.xml.soap.SOAPFault; //导入依赖的package包/类
public void _testQuick() throws Exception {
    MessageFactory msgfactory = MessageFactory.newInstance();
    SOAPFactory factory = SOAPFactory.newInstance();
    SOAPMessage outputmsg = msgfactory.createMessage();
    String valueCode = "faultcode";
    String valueString = "faultString";
    SOAPFault fault = outputmsg.getSOAPPart().getEnvelope().getBody().addFault();
    fault.setFaultCode(valueCode);
    fault.setFaultString(valueString);
    Detail detail = fault.addDetail();
    detail.addDetailEntry(factory.createName("Hello"));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    if (outputmsg.saveRequired()) {
        outputmsg.saveChanges();
    }
    outputmsg.writeTo(baos);
    String xml = new String(baos.toByteArray());
    assertTrue(xml.indexOf("Hello") != -1);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:20,代码来源:SOAPFaultTest.java

示例5: 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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:SOAP11Fault.java

示例6: fillFaultSubCodes

import javax.xml.soap.SOAPFault; //导入依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:SOAP12Fault.java

示例7: addFault

import javax.xml.soap.SOAPFault; //导入依赖的package包/类
@Override
public SOAPFault addFault() throws SOAPException {
    if (hasFault()) {
        log.severe("SAAJ0110.impl.fault.already.exists");
        throw new SOAPExceptionImpl("Error: Fault already exists");
    }

    fault = createFaultElement();

    addNode(fault);

    fault.setFaultCode(getDefaultFaultCode());
    fault.setFaultString("Fault string, and possibly fault code, not set");

    return fault;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:BodyImpl.java

示例8: 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;
}
 
开发者ID:cecid,项目名称:hermes,代码行数:35,代码来源:SOAPResponse.java

示例9: invoke

import javax.xml.soap.SOAPFault; //导入依赖的package包/类
@Override
public DOMSource invoke(DOMSource request) {
    try {
        return invokeAllowingFaults(request);
    } catch (FaultMessage faultMessage) {
        try {
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault();
            soapFault.setFaultCode(SOAP11_FAULTCODE_SERVER);           // todo here is a constant until we have a mechanism to determine the correct value (client / server)
            soapFault.setFaultString(faultMessage.getMessage());
            Detail detail = soapFault.addDetail();
            serializeFaultMessage(detail, faultMessage);
            // fault actor?
            // stack trace of the outer exception (FaultMessage) is unimportant, because it is always created at one place
            // todo consider providing stack trace of the inner exception
            //Detail detail = soapFault.addDetail();
            //detail.setTextContent(getStackTraceAsString(faultMessage));
            throw new SOAPFaultException(soapFault);
        } catch (SOAPException e) {
            throw new RuntimeException("SOAP Exception: " + e.getMessage(), e);
        }
    }
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:24,代码来源:ModelWebServiceRaw.java

示例10: invoke

import javax.xml.soap.SOAPFault; //导入依赖的package包/类
public SOAPMessage invoke(SOAPMessage requestSoapMessage)
   {
      SOAPFault theSOAPFault;
      try {
         theSOAPFault = SOAPFactory.newInstance().createFault();
         Detail soapFaultDetail = theSOAPFault.addDetail();
         SOAPElement myFaultElement = soapFaultDetail.addChildElement(new QName("http://www.my-company.it/ws/my-test", "MyWSException"));
         SOAPElement myMessageElement = myFaultElement.addChildElement(new QName("http://www.my-company.it/ws/my-test", "message"));
//         myMessageElement.setNodeValue("This is a faked error"); //wrong: myMessageElement is not a text node
         myMessageElement.setValue("This is a faked error"); //right: this creates a text node and gives it a text value
      } catch (SOAPException se) {
         se.printStackTrace();
         throw new RuntimeException("Something unexpected happened!");
      }
      throw new SOAPFaultException(theSOAPFault);
   }
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:17,代码来源:ProviderImpl.java

示例11: handleOutbound

import javax.xml.soap.SOAPFault; //导入依赖的package包/类
protected boolean handleOutbound(final SOAPMessageContext msgContext)
{
   try
   {
      SOAPFault fault = null;
      MessageFactory factory = MessageFactory.newInstance(); 
      SOAPMessage resMessage = factory.createMessage();
      fault = resMessage.getSOAPBody().addFault();
      fault.setFaultString("this is an exception thrown by client outbound");
      throw new SOAPFaultException(fault);
   }
   catch (SOAPException e)
   {
      //ignore
   }
   return true;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:18,代码来源:ClientSOAPHandler.java

示例12: 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);
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:17,代码来源:EndpointImpl.java

示例13: 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

示例14: 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

示例15: testIllegalMessageAccess

import javax.xml.soap.SOAPFault; //导入依赖的package包/类
@Test
@RunAsClient
public void testIllegalMessageAccess() throws Exception
{
   MessageFactory msgFactory = MessageFactory.newInstance();
   SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();

   String reqEnv =
      "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
      " <env:Header/>" +
      " <env:Body>" +
      "  <ns1:noWebMethod xmlns:ns1='" + targetNS + "'>" +
      "   <String_1>Hello</String_1>" +
      "  </ns1:noWebMethod>" +
      " </env:Body>" +
      "</env:Envelope>";
   SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));

   URL epURL = new URL(baseURL + "/TestService");
   SOAPMessage resMsg = con.call(reqMsg, epURL);
   SOAPFault soapFault = resMsg.getSOAPBody().getFault();
   assertNotNull("Expected SOAPFault", soapFault);

   String faultString = soapFault.getFaultString();
   assertTrue(faultString, faultString.indexOf("noWebMethod") > 0);
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:27,代码来源:WebMethodTestCase.java


注:本文中的javax.xml.soap.SOAPFault类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。