javax.xml.ws.WebServiceException Java Examples

The following examples show how to use javax.xml.ws.WebServiceException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WsaClientTube.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void validateAction(Packet packet) {
    //There may not be a WSDL operation.  There may not even be a WSDL.
    //For instance this may be a RM CreateSequence message.
    WSDLBoundOperation wbo = getWSDLBoundOperation(packet);

    if (wbo == null)    return;

    String gotA = AddressingUtils.getAction(
            packet.getMessage().getHeaders(),
            addressingVersion, soapVersion);
    if (gotA == null)
        throw new WebServiceException(AddressingMessages.VALIDATION_CLIENT_NULL_ACTION());

    String expected = helper.getOutputAction(packet);

    if (expected != null && !gotA.equals(expected))
        throw new ActionNotSupportedException(gotA);
}
 
Example #2
Source File: LogicalMessageImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public Object getPayload(BindingContext context) {
    if (context == null) {
        context = defaultJaxbContext;
    }
    if (context == null)
        throw new WebServiceException("JAXBContext parameter cannot be null");

    Object o;
    if (lm == null) {
        try {
            o = packet.getMessage().copy().readPayloadAsJAXB(context.createUnmarshaller());
        } catch (JAXBException e) {
            throw new WebServiceException(e);
        }
    } else {
        o = lm.getPayload(context);
        lm = new JAXBLogicalMessageImpl(context.getJAXBContext(), o);
    }
    return o;
}
 
Example #3
Source File: IntraHubServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public PutAccessRightResponse putAccessRight(SAMLToken token, PutAccessRightRequest request) throws IntraHubBusinessConnectorException, TechnicalConnectorException {
   request.setRequest(RequestTypeBuilder.init().addGenericAuthor().build());

   try {
      GenericRequest genReq = ServiceFactory.getIntraHubPort(token, "urn:be:fgov:ehealth:interhub:protocol:v1:PutAccessRight");
      genReq.setPayload((Object)request);
      GenericResponse genResp = be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(genReq);
      return (PutAccessRightResponse)genResp.asObject(PutAccessRightResponse.class);
   } catch (SOAPException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var5, new Object[]{var5.getMessage()});
   } catch (WebServiceException var6) {
      throw ServiceHelper.handleWebServiceException(var6);
   } catch (MalformedURLException var7) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var7, new Object[]{var7.getMessage()});
   }
}
 
Example #4
Source File: WsaClientTube.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void validateAction(Packet packet) {
    //There may not be a WSDL operation.  There may not even be a WSDL.
    //For instance this may be a RM CreateSequence message.
    WSDLBoundOperation wbo = getWSDLBoundOperation(packet);

    if (wbo == null)    return;

    String gotA = AddressingUtils.getAction(
            packet.getMessage().getHeaders(),
            addressingVersion, soapVersion);
    if (gotA == null)
        throw new WebServiceException(AddressingMessages.VALIDATION_CLIENT_NULL_ACTION());

    String expected = helper.getOutputAction(packet);

    if (expected != null && !gotA.equals(expected))
        throw new ActionNotSupportedException(gotA);
}
 
Example #5
Source File: LogicalMessageImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public Object getPayload(BindingContext context) {
    if (context == null) {
        context = defaultJaxbContext;
    }
    if (context == null)
        throw new WebServiceException("JAXBContext parameter cannot be null");

    Object o;
    if (lm == null) {
        try {
            o = packet.getMessage().copy().readPayloadAsJAXB(context.createUnmarshaller());
        } catch (JAXBException e) {
            throw new WebServiceException(e);
        }
    } else {
        o = lm.getPayload(context);
        lm = new JAXBLogicalMessageImpl(context.getJAXBContext(), o);
    }
    return o;
}
 
Example #6
Source File: DatabindingFactoryImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
Properties loadPropertiesFile(String fileName) {
        ClassLoader classLoader = classLoader();
        Properties p = new Properties();
        try {
                InputStream is = null;
                if (classLoader == null) {
                        is = ClassLoader.getSystemResourceAsStream(fileName);
                } else {
                        is = classLoader.getResourceAsStream(fileName);
                }
                if (is != null) {
                        p.load(is);
                }
        } catch (Exception e) {
                throw new WebServiceException(e);
        }
        return p;
}
 
Example #7
Source File: WSEndpointReference.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param writer the writer should be at the start of element.
 * @param service Namespace URI of servcie is used as targetNamespace of wsdl if wsdlTargetNamespace is not null
 * @param wsdlAddress  wsdl location
 * @param wsdlTargetNamespace  targetnamespace of wsdl to be put in wsdliLocation
 *
 */
private static void writeWsdliLocation(StreamWriterBufferCreator writer, QName service,String wsdlAddress,String wsdlTargetNamespace) throws XMLStreamException {
    String wsdliLocation = "";
    if(wsdlTargetNamespace != null) {
       wsdliLocation = wsdlTargetNamespace + " ";
    } else if (service != null) {
        wsdliLocation = service.getNamespaceURI() + " ";
    } else {
        throw new WebServiceException("WSDL target Namespace cannot be resolved");
    }
    wsdliLocation += wsdlAddress;
    writer.writeNamespace(W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_PREFIX,
        W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_NAMESPACE);
    writer.writeAttribute(W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_PREFIX,
            W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_NAMESPACE,
            W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_LOCALNAME,
            wsdliLocation);

}
 
Example #8
Source File: EndpointAddress.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tries to open {@link URLConnection} for this endpoint.
 *
 * <p>
 * This is possible only when an endpoint address has
 * the corresponding {@link URLStreamHandler}.
 *
 * @throws IOException
 *      if {@link URL#openConnection()} reports an error.
 * @throws AssertionError
 *      if this endpoint doesn't have an associated URL.
 *      if the code is written correctly this shall never happen.
 */
public URLConnection openConnection() throws IOException {
    if (url == null) {
        throw new WebServiceException("URI="+uri+" doesn't have the corresponding URL");
    }
    if(proxy!=null && !dontUseProxyMethod) {
        try {
            return url.openConnection(proxy);
        } catch(UnsupportedOperationException e) {
            // Some OSGi and app server environments donot
            // override URLStreamHandler.openConnection(URL, Proxy) as it
            // is introduced in Java SE 5 API. Fallback to the other method.
            dontUseProxyMethod = true;
        }
    }
    return url.openConnection();
}
 
Example #9
Source File: IntraHubServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public GetAccessRightResponse getAccessRight(SAMLToken token, GetAccessRightRequest request) throws IntraHubBusinessConnectorException, TechnicalConnectorException {
   request.setRequest(RequestTypeBuilder.init().addGenericAuthor().build());

   try {
      GenericRequest genReq = ServiceFactory.getIntraHubPort(token, "urn:be:fgov:ehealth:interhub:protocol:v1:GetAccessRight");
      genReq.setPayload((Object)request);
      GenericResponse genResp = be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(genReq);
      return (GetAccessRightResponse)genResp.asObject(GetAccessRightResponse.class);
   } catch (SOAPException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var5, new Object[]{var5.getMessage()});
   } catch (WebServiceException var6) {
      throw ServiceHelper.handleWebServiceException(var6);
   } catch (MalformedURLException var7) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var7, new Object[]{var7.getMessage()});
   }
}
 
Example #10
Source File: SOAP12Fault.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #11
Source File: IntraHubServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public RevokePatientConsentResponse revokePatientConsent(SAMLToken token, RevokePatientConsentRequest request) throws IntraHubBusinessConnectorException, TechnicalConnectorException {
   request.setRequest(RequestTypeBuilder.init().addGenericAuthor().build());

   try {
      GenericRequest genReq = ServiceFactory.getIntraHubPort(token, "urn:be:fgov:ehealth:interhub:protocol:v1:RevokePatientConsent");
      genReq.setPayload((Object)request);
      GenericResponse genResp = be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(genReq);
      return (RevokePatientConsentResponse)genResp.asObject(RevokePatientConsentResponse.class);
   } catch (SOAPException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var5, new Object[]{var5.getMessage()});
   } catch (WebServiceException var6) {
      throw ServiceHelper.handleWebServiceException(var6);
   } catch (MalformedURLException var7) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var7, new Object[]{var7.getMessage()});
   }
}
 
Example #12
Source File: EndpointResponseMessageBuilder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Packs a bunch of arguments intoa {@link WrapperComposite}.
 */
WrapperComposite buildWrapperComposite(Object[] methodArgs, Object returnValue) {
    WrapperComposite cs = new WrapperComposite();
    cs.bridges = parameterBridges;
    cs.values = new Object[parameterBridges.length];

    // fill in wrapped parameters from methodArgs
    for( int i=indices.length-1; i>=0; i-- ) {
        Object v;
        if (indices[i] == -1) {
            v = getters[i].get(returnValue);
        } else {
            v = getters[i].get(methodArgs[indices[i]]);
        }
        if(v==null) {
            throw new WebServiceException("Method Parameter: "+
                children.get(i).getName() +" cannot be null. This is BP 1.1 R2211 violation.");
        }
        cs.values[i] = v;
    }

    return cs;
}
 
Example #13
Source File: ServerSOAPHandlerTube.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
void callHandlersOnResponse(MessageUpdatableContext context, boolean handleFault) {

        //Lets copy all the MessageContext.OUTBOUND_ATTACHMENT_PROPERTY to the message
        Map<String, DataHandler> atts = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
        AttachmentSet attSet = context.packet.getMessage().getAttachments();
        for (Map.Entry<String, DataHandler> entry : atts.entrySet()) {
            String cid = entry.getKey();
            if (attSet.get(cid) == null) { // Otherwise we would be adding attachments twice
                Attachment att = new DataHandlerAttachment(cid, atts.get(cid));
                attSet.add(att);
            }
        }

        try {
            //SERVER-SIDE
            processor.callHandlersResponse(HandlerProcessor.Direction.OUTBOUND, context, handleFault);

        } catch (WebServiceException wse) {
            //no rewrapping
            throw wse;
        } catch (RuntimeException re) {
            throw re;

        }
    }
 
Example #14
Source File: BodyBuilder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a {@link BodyBuilder} from a {@link WrapperParameter}.
 */
DocLit(WrapperParameter wp, SOAPVersion soapVersion, ValueGetterFactory getter) {
    super(wp, soapVersion, getter);
    bindingContext = wp.getOwner().getBindingContext();
    wrapper = (Class)wp.getXMLBridge().getTypeInfo().type;
    dynamicWrapper = WrapperComposite.class.equals(wrapper);
    parameterBridges = new XMLBridge[children.size()];
    accessors = new PropertyAccessor[children.size()];
    for( int i=0; i<accessors.length; i++ ) {
        ParameterImpl p = children.get(i);
        QName name = p.getName();
        if (dynamicWrapper) {
            parameterBridges[i] = children.get(i).getInlinedRepeatedElementBridge();
            if (parameterBridges[i] == null) parameterBridges[i] = children.get(i).getXMLBridge();
        } else {
            try {
                accessors[i] = p.getOwner().getBindingContext().getElementPropertyAccessor(
                    wrapper, name.getNamespaceURI(), name.getLocalPart() );
            } catch (JAXBException e) {
                throw new WebServiceException(  // TODO: i18n
                    wrapper+" do not have a property of the name "+name,e);
            }
        }
    }

}
 
Example #15
Source File: ServerSOAPHandlerTube.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void callHandlersOnResponse(MessageUpdatableContext context, boolean handleFault) {

        //Lets copy all the MessageContext.OUTBOUND_ATTACHMENT_PROPERTY to the message
        Map<String, DataHandler> atts = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
        AttachmentSet attSet = context.packet.getMessage().getAttachments();
        for (Map.Entry<String, DataHandler> entry : atts.entrySet()) {
            String cid = entry.getKey();
            if (attSet.get(cid) == null) { // Otherwise we would be adding attachments twice
                Attachment att = new DataHandlerAttachment(cid, atts.get(cid));
                attSet.add(att);
            }
        }

        try {
            //SERVER-SIDE
            processor.callHandlersResponse(HandlerProcessor.Direction.OUTBOUND, context, handleFault);

        } catch (WebServiceException wse) {
            //no rewrapping
            throw wse;
        } catch (RuntimeException re) {
            throw re;

        }
    }
 
Example #16
Source File: MimeMultipartParser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] asByteArray() {
    if (buf == null) {
        ByteArrayBuffer baf = new ByteArrayBuffer();
        try {
            baf.write(part.readOnce());
        } catch(IOException ioe) {
            throw new WebServiceException(ioe);
        } finally {
            if (baf != null) {
                try {
                    baf.close();
                } catch (IOException ex) {
                    Logger.getLogger(MimeMultipartParser.class.getName()).log(Level.FINE, null, ex);
                }
            }
        }
        buf = baf.toByteArray();
    }
    return buf;
}
 
Example #17
Source File: Stubs.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portInfo
 *      see <a href="#param">common parameters</a>
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createPacketDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Packet>");
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
 
Example #18
Source File: JAXBMessage.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public XMLStreamReader readPayload() throws XMLStreamException {
   try {
        if(infoset==null) {
                            if (rawContext != null) {
                    XMLStreamBufferResult sbr = new XMLStreamBufferResult();
                                    Marshaller m = rawContext.createMarshaller();
                                    m.setProperty("jaxb.fragment", Boolean.TRUE);
                                    m.marshal(jaxbObject, sbr);
                    infoset = sbr.getXMLStreamBuffer();
                            } else {
                                MutableXMLStreamBuffer buffer = new MutableXMLStreamBuffer();
                                writePayloadTo(buffer.createFromXMLStreamWriter());
                                infoset = buffer;
                            }
        }
        XMLStreamReader reader = infoset.readAsXMLStreamReader();
        if(reader.getEventType()== START_DOCUMENT)
            XMLStreamReaderUtil.nextElementContent(reader);
        return reader;
    } catch (JAXBException e) {
       // bug 6449684, spec 4.3.4
       throw new WebServiceException(e);
    }
}
 
Example #19
Source File: DispatchImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void checkError() {
    if (error != null) {
        if (getBinding() instanceof SOAPBinding) {
            SOAPFault soapFault = null;
            try {
                soapFault = JaxWsClientProxy.createSoapFault((SOAPBinding)getBinding(),
                                                             new Exception(error.toString()));
            } catch (SOAPException e) {
                //ignore
            }
            if (soapFault != null) {
                throw new SOAPFaultException(soapFault);
            }
        } else if (getBinding() instanceof HTTPBinding) {
            HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
            exception.initCause(new Exception(error.toString()));
            throw exception;
        }
        throw new WebServiceException(error.toString());
    }
}
 
Example #20
Source File: EndpointFactory.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies whether the given primaryWsdl contains the given serviceName.
 * If the WSDL doesn't have the service, it throws an WebServiceException.
 */
private static void verifyPrimaryWSDL(@NotNull SDDocumentSource primaryWsdl, @NotNull QName serviceName) {
    SDDocumentImpl primaryDoc = SDDocumentImpl.create(primaryWsdl,serviceName,null);
    if (!(primaryDoc instanceof SDDocument.WSDL)) {
        throw new WebServiceException(primaryWsdl.getSystemId()+
                " is not a WSDL. But it is passed as a primary WSDL");
    }
    SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)primaryDoc;
    if (!wsdlDoc.hasService()) {
        if(wsdlDoc.getAllServices().isEmpty())
            throw new WebServiceException("Not a primary WSDL="+primaryWsdl.getSystemId()+
                    " since it doesn't have Service "+serviceName);
        else
            throw new WebServiceException("WSDL "+primaryDoc.getSystemId()
                    +" has the following services "+wsdlDoc.getAllServices()
                    +" but not "+serviceName+". Maybe you forgot to specify a serviceName and/or targetNamespace in @WebService/@WebServiceProvider?");
    }
}
 
Example #21
Source File: LetterOfCreditFundServiceImpl.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Collection findMatching(Map fieldValues) {
    AwardMethodOfPaymentDTO criteria = new AwardMethodOfPaymentDTO();
    List<AwardMethodOfPaymentDTO> result = null;

    try {
        if (fieldValues.containsKey("letterOfCreditFundGroupCode")
                && StringUtils.length((String) fieldValues.get("letterOfCreditFundGroupCode")) > 0) {
            result = this.getWebService().getMatchingMethodOfPaymentsForBasisOfPayment((String) fieldValues.get("letterOfCreditFundGroupCode"));
        } else {
            criteria.setMethodOfPaymentCode((String) fieldValues.get("letterOfCreditFundCode"));
            criteria.setDescription((String) fieldValues.get("letterOfCreditFundDescription"));
            result  = this.getWebService().getMatchingMethodOfPayments(criteria);
        }
    } catch (WebServiceException ex) {
        GlobalVariablesExtractHelper.insertError(KcConstants.WEBSERVICE_UNREACHABLE, getConfigurationService().getPropertyValueAsString(KFSConstants.KC_APPLICATION_URL_KEY));
    }

    List<LetterOfCreditFund> methods = new ArrayList<LetterOfCreditFund>();
    if (result != null) {
        for (AwardMethodOfPaymentDTO dto : result) {
            methods.add(fundFromDTO(dto));
        }
    }
    return methods;
}
 
Example #22
Source File: ClientLogicalHandlerTube.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
boolean callHandlersOnRequest(MessageUpdatableContext context, boolean isOneWay) {

        boolean handlerResult;
        try {

            //CLIENT-SIDE
            handlerResult = processor.callHandlersRequest(HandlerProcessor.Direction.OUTBOUND, context, !isOneWay);
        } catch (WebServiceException wse) {
            remedyActionTaken = true;
            //no rewrapping
            throw wse;
        } catch (RuntimeException re) {
            remedyActionTaken = true;

            throw new WebServiceException(re);

        }
        if (!handlerResult) {
            remedyActionTaken = true;
        }
        return handlerResult;
    }
 
Example #23
Source File: SafePolicyReader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reads policy reference element <wsp:PolicyReference/> and returns referenced policy URI as String
 *
 * @param reader The XMLStreamReader should be in START_ELEMENT state and point to the PolicyReference element.
 * @return The URI contained in the PolicyReference
 */
public String readPolicyReferenceElement(final XMLStreamReader reader) {
    try {
        if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.PolicyReference) {     // "PolicyReference" element interests me
            for (int i = 0; i < reader.getAttributeCount(); i++) {
                if (XmlToken.resolveToken(reader.getAttributeName(i).getLocalPart()) == XmlToken.Uri) {
                    final String uriValue = reader.getAttributeValue(i);
                    reader.next();
                    return uriValue;
                }
            }
        }
        reader.next();
        return null;
    } catch(XMLStreamException e) {
        throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1001_XML_EXCEPTION_WHEN_PROCESSING_POLICY_REFERENCE(), e));
    }
}
 
Example #24
Source File: PolicyWSDLGeneratorExtension.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds a PolicyReference element that points to the policy of the element,
 * if the policy does not have any id or name. Writes policy inside the element otherwise.
 *
 * @param subject
 *      PolicySubject to be referenced or marshalled
 * @param writer
 *      A TXW on to which we shall add the PolicyReference
 */
private void writePolicyOrReferenceIt(final PolicySubject subject, final TypedXmlWriter writer) {
    final Policy policy;
    try {
        policy = subject.getEffectivePolicy(merger);
    } catch (PolicyException e) {
        throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1011_FAILED_TO_RETRIEVE_EFFECTIVE_POLICY_FOR_SUBJECT(subject.toString()), e));
    }
    if (policy != null) {
        if (null == policy.getIdOrName()) {
            final PolicyModelGenerator generator = ModelGenerator.getGenerator();
            try {
                final PolicySourceModel policyInfoset = generator.translate(policy);
                marshaller.marshal(policyInfoset, writer);
            } catch (PolicyException pe) {
                throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1002_UNABLE_TO_MARSHALL_POLICY_OR_POLICY_REFERENCE(), pe));
            }
        } else {
            final TypedXmlWriter policyReference = writer._element(policy.getNamespaceVersion().asQName(XmlToken.PolicyReference), TypedXmlWriter.class);
            policyReference._attribute(XmlToken.Uri.toString(), '#' + policy.getIdOrName());
        }
    }
}
 
Example #25
Source File: InjectionPlan.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static boolean isInjectionPoint(Resource resource, Class fieldType, String errorMessage, Class resourceType ) {
    Class t = resource.type();
    if (t.equals(Object.class)) {
        return fieldType.equals(resourceType);
    } else if (t.equals(resourceType)) {
        if (fieldType.isAssignableFrom(resourceType)) {
            return true;
        } else {
            // type compatibility error
            throw new WebServiceException(errorMessage);
        }
    }
    return false;
}
 
Example #26
Source File: WSDLGenResolver.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * At present, it returns file URL scheme eventhough there is no resource
 * in the filesystem.
 *
 * @return URL of the generated document
 *
 */
private URL createURL(String filename) {
    try {
        return new URL("file:///"+filename);
    } catch (MalformedURLException e) {
        // TODO: I really don't think this is the right way to handle this error,
        // WSDLResolver needs to be documented carefully.
        throw new WebServiceException(e);
    }
}
 
Example #27
Source File: ServiceGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void writeAbsWSDLLocation(JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
    JBlock staticBlock = cls.init();
    JVar urlVar = staticBlock.decl(cm.ref(URL.class), "url", JExpr._null());
    JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());

    JTryBlock tryBlock = staticBlock._try();
    tryBlock.body().assign(urlVar, JExpr._new(cm.ref(URL.class)).arg(wsdlLocation));
    JCatchBlock catchBlock = tryBlock._catch(cm.ref(MalformedURLException.class));
    catchBlock.param("ex");
    catchBlock.body().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(JExpr.ref("ex")));

    staticBlock.assign(urlField, urlVar);
    staticBlock.assign(exField, exVar);
}
 
Example #28
Source File: ManagedClientAssertion.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return ManagedClient assertion if there is one associated with the client.
 *
 * @param portInfo The client PortInfo.
 * @return The policy assertion if found. Null otherwise.
 * @throws WebServiceException If computing the effective policy of the port failed.
 */
public static ManagedClientAssertion getAssertion(WSPortInfo portInfo) throws WebServiceException {
    if (portInfo == null)
            return null;

    LOGGER.entering(portInfo);
    // getPolicyMap is deprecated because it is only supposed to be used by Metro code
    // and not by other clients.
    @SuppressWarnings("deprecation")
    final PolicyMap policyMap = portInfo.getPolicyMap();
    final ManagedClientAssertion assertion = ManagementAssertion.getAssertion(MANAGED_CLIENT_QNAME,
            policyMap, portInfo.getServiceName(), portInfo.getPortName(), ManagedClientAssertion.class);
    LOGGER.exiting(assertion);
    return assertion;
}
 
Example #29
Source File: ClientSchemaValidationTube.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public ClientSchemaValidationTube(WSBinding binding, WSDLPort port, Tube next) {
    super(binding, next);
    this.port = port;
    if (port != null) {
        String primaryWsdl = port.getOwner().getParent().getLocation().getSystemId();
        MetadataResolverImpl mdresolver = new MetadataResolverImpl();
        Map<String, SDDocument> docs = MetadataUtil.getMetadataClosure(primaryWsdl, mdresolver, true);
        mdresolver = new MetadataResolverImpl(docs.values());
        Source[] sources = getSchemaSources(docs.values(), mdresolver);
        for(Source source : sources) {
            LOGGER.fine("Constructing client validation schema from = "+source.getSystemId());
            //printDOM((DOMSource)source);
        }
        if (sources.length != 0) {
            noValidation = false;
            sf.setResourceResolver(mdresolver);
            try {
                schema = sf.newSchema(sources);
            } catch(SAXException e) {
                throw new WebServiceException(e);
            }
            validator = schema.newValidator();
            return;
        }
    }
    noValidation = true;
    schema = null;
    validator = null;
}
 
Example #30
Source File: HubTokenServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
private <T> T executeOperation(SAMLToken token, Object request, String operation, Class<T> clazz) throws TechnicalConnectorException {
   try {
      GenericRequest service = ServiceFactory.getIntraHubPort(token, operation).setPayload(request);
      return be.ehealth.technicalconnector.ws.ServiceFactory.getGenericWsSender().send(service).asObject(clazz);
   } catch (SOAPException var6) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, var6, new Object[]{var6.getMessage()});
   } catch (WebServiceException var7) {
      throw ServiceHelper.handleWebServiceException(var7);
   }
}