Ejemplo n.º 1
0
  private SOAPFaultException createSOAPFaultException() {
    try {
      String namespace = "http://example.com/auctiontraq/schemas/doclit";
      SOAPFactory soapFactory = SOAPFactory.newInstance();
      Name name = soapFactory.createName("MySOAPFault", "ns0", namespace);
      Detail detail = soapFactory.createDetail();
      DetailEntry entry = detail.addDetailEntry(name);
      entry.addNamespaceDeclaration("data", namespace);
      Name attrName1 = soapFactory.createName("myAttr", "data", namespace);
      entry.addAttribute(attrName1, "myvalue");
      SOAPElement child = entry.addChildElement("message");
      child.addTextNode("Server Exception");

      Name name2 = soapFactory.createName("ExtraInformation", "ns0", namespace);
      DetailEntry entry2 = detail.addDetailEntry(name2);

      SOAPElement child2 = entry2.addChildElement("Reason");
      child2.addTextNode("Address Not Found");

      QName qname = new QName("http://schemas.xmlsoap.org/soap/envelope/", "server");
      SOAPFault sf = soapFactory.createFault("SOAP Fault Exception:Address Not Found", qname);
      org.w3c.dom.Node n = sf.getOwnerDocument().importNode(detail, true);
      sf.appendChild(n);
      return new SOAPFaultException(sf);
      // printDetail(detail);
      // return new SOAPFaultException(qname,
      //       "SOAP Fault Exception:Address Not Found", null, detail);

    } catch (SOAPException e) {
      e.printStackTrace();
      // QName qname = new QName("http://schemas.xmlsoap.org/soap/envelope/", "client");
      throw new WebServiceException("Exception While Creating SOAP Fault Exception", e);
    }
  }
  public CreateCoordinationContextResponseType createCoordinationContext(
      final CreateCoordinationContextType createCoordinationContext,
      final MAP map,
      boolean isSecure) {
    final String messageId = map.getMessageID();
    synchronized (messageIdMap) {
      messageIdMap.put(
          messageId, new CreateCoordinationContextDetails(createCoordinationContext, map));
      messageIdMap.notifyAll();
    }
    String coordinationType = createCoordinationContext.getCoordinationType();
    if (TestUtil.INVALID_CREATE_PARAMETERS_COORDINATION_TYPE.equals(coordinationType)) {
      try {
        SOAPFactory factory = SOAPFactory.newInstance();
        SOAPFault soapFault =
            factory.createFault(
                SoapFaultType.FAULT_SENDER.getValue(),
                CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME);
        soapFault
            .addDetail()
            .addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME)
            .addTextNode("Invalid create parameters");
        throw new SOAPFaultException(soapFault);
      } catch (Throwable th) {
        throw new ProtocolException(th);
      }
    }

    // we have to return a value so lets cook one up

    CreateCoordinationContextResponseType createCoordinationContextResponseType =
        new CreateCoordinationContextResponseType();
    CoordinationContext coordinationContext = new CoordinationContext();
    coordinationContext.setCoordinationType(coordinationType);
    coordinationContext.setExpires(createCoordinationContext.getExpires());
    String identifier = nextIdentifier();
    CoordinationContextType.Identifier identifierInstance =
        new CoordinationContextType.Identifier();
    identifierInstance.setValue(identifier);
    coordinationContext.setIdentifier(identifierInstance);
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    builder.serviceName(CoordinationConstants.REGISTRATION_SERVICE_QNAME);
    builder.endpointName(CoordinationConstants.REGISTRATION_ENDPOINT_QNAME);
    builder.address(TestUtil.PROTOCOL_COORDINATOR_SERVICE);
    W3CEndpointReference registrationService = builder.build();
    coordinationContext.setRegistrationService(TestUtil11.getRegistrationEndpoint(identifier));
    createCoordinationContextResponseType.setCoordinationContext(coordinationContext);

    return createCoordinationContextResponseType;
  }