Ejemplo n.º 1
0
 @Test
 public final void testGetFaultCodeAsNameQualified() throws Exception {
   SOAPFault fault = createEmptySOAPFault();
   String code = fault.getPrefix() + ":Server";
   appendFaultCodeElement(fault).setTextContent(code);
   Name name = fault.getFaultCodeAsName();
   assertEquals(fault.getPrefix(), name.getPrefix());
   assertEquals(fault.getNamespaceURI(), name.getURI());
   assertEquals("Server", name.getLocalName());
 }
Ejemplo n.º 2
0
 @Validated
 @Test
 public final void testGetFaultCode() throws Exception {
   SOAPFault fault = createEmptySOAPFault();
   String code = fault.getPrefix() + ":Server";
   appendFaultCodeElement(fault).setTextContent(code);
   assertEquals(code, fault.getFaultCode());
 }
Ejemplo n.º 3
0
 /**
  * Creates a SOAPFault element from SOS exception
  *
  * @param soapFault SOAPFault element
  * @param owsExceptionReport SOS exception
  * @return SOAP action URI.
  * @throws SOAPException if an error occurs.
  */
 protected String createSOAPFaultFromExceptionResponse(
     SOAPFault soapFault, OwsExceptionReport owsExceptionReport) throws SOAPException {
   // FIXME: check and fix support for ExceptionReport with multiple
   // exceptions!
   if (!owsExceptionReport.getExceptions().isEmpty()) {
     CodedException firstException = owsExceptionReport.getExceptions().iterator().next();
     if (soapFault.getNamespaceURI().equalsIgnoreCase(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
       QName qname = new QName(soapFault.getNamespaceURI(), "Client", soapFault.getPrefix());
       soapFault.setFaultCode(qname);
     } else {
       soapFault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
       if (firstException.getCode() != null) {
         soapFault.appendFaultSubcode(
             new QName(
                 OWSConstants.NS_OWS,
                 firstException.getCode().toString(),
                 OWSConstants.NS_OWS_PREFIX));
       } else {
         soapFault.appendFaultSubcode(OWSConstants.QN_NO_APPLICABLE_CODE);
       }
     }
     soapFault.addFaultReasonText(
         SoapHelper.getSoapFaultReasonText(firstException.getCode()), Locale.ENGLISH);
     Detail detail = soapFault.addDetail();
     for (CodedException exception : owsExceptionReport.getExceptions()) {
       createSOAPFaultDetail(detail, exception);
     }
     return getExceptionActionURI(firstException.getCode());
   } else {
     SoapFault fault = new SoapFault();
     fault.setFaultCode(SOAPConstants.SOAP_RECEIVER_FAULT);
     fault.setFaultSubcode(OWSConstants.QN_NO_APPLICABLE_CODE);
     fault.setFaultReason(DEFAULT_FAULT_REASON);
     fault.setLocale(Locale.ENGLISH);
     fault.setDetailText(MISSING_EXCEPTION_DETAIL_TEXT);
     createSOAPFault(soapFault, fault);
     return SosSoapConstants.RESP_ACTION_SOS;
   }
 }
Ejemplo n.º 4
0
 @Override
 protected SOAPElement appendFaultCodeElement(SOAPFault fault) throws SOAPException {
   SOAPElement code =
       fault.addChildElement(new QName(fault.getNamespaceURI(), "Code", fault.getPrefix()));
   return code.addChildElement(new QName(fault.getNamespaceURI(), "Value", fault.getPrefix()));
 }