Java Code Examples for javax.xml.ws.WebServiceException

The following examples show how to use javax.xml.ws.WebServiceException. These examples are extracted from open source projects. 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 Project: openjdk-8   Author: bpupadhyaya   File: LogicalMessageImpl.java    License: 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 #2
Source Project: openjdk-8-source   Author: keerath   File: LogicalMessageImpl.java    License: 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 Project: openjdk-8-source   Author: keerath   File: WSEndpointReference.java    License: 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 #4
Source Project: openjdk-8-source   Author: keerath   File: WsaClientTube.java    License: 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
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 #6
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: DatabindingFactoryImpl.java    License: 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 Project: openjdk-8   Author: bpupadhyaya   File: EndpointAddress.java    License: 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 #8
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 #9
Source Project: openjdk-8   Author: bpupadhyaya   File: SOAP12Fault.java    License: 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 #10
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 #11
Source Project: openjdk-8   Author: bpupadhyaya   File: EndpointResponseMessageBuilder.java    License: 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 #12
Source Project: jdk8u60   Author: chenghanpeng   File: PolicyWSDLGeneratorExtension.java    License: 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 #13
Source Project: TencentKona-8   Author: Tencent   File: BodyBuilder.java    License: 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 #14
Source Project: jdk8u60   Author: chenghanpeng   File: ServerSOAPHandlerTube.java    License: 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 #15
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: SafePolicyReader.java    License: 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 #16
Source Project: jdk8u60   Author: chenghanpeng   File: ClientLogicalHandlerTube.java    License: 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 #17
Source Project: kfs   Author: kuali   File: LetterOfCreditFundServiceImpl.java    License: 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 #18
Source Project: openjdk-8-source   Author: keerath   File: EndpointFactory.java    License: 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 #19
Source Project: cxf   Author: apache   File: DispatchImpl.java    License: 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 Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: JAXBMessage.java    License: 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 #21
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: Stubs.java    License: 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 #22
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: MimeMultipartParser.java    License: 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 #23
Source Project: TencentKona-8   Author: Tencent   File: ServerSOAPHandlerTube.java    License: 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 #24
Source Project: hottub   Author: dsrg-uoft   File: WsaClientTube.java    License: 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 #25
Source Project: development   Author: servicecatalog   File: MockSTSWSTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSecuredWS_Modify_Issuer() throws Exception {
    idS = ServiceFactory.getSTSServiceFactory().getIdentityService(
            "MockSTSTest_Issuer", "admin123");
    try {
        invokeWSMethod();
        fail();
    } catch (WebServiceException e) {
        assertThat(e.getMessage(), containsString(EXCEPTION_SUBSTRING));
    }
}
 
Example #26
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: LogicalMessageImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Source getPayload() {
    JAXBContext context = ctxt;
    if (context == null) {
        context = defaultJaxbContext.getJAXBContext();
    }
    try {
        return new JAXBSource(context, o);
    } catch (JAXBException e) {
        throw new WebServiceException(e);
    }
}
 
Example #27
Source Project: openjdk-8-source   Author: keerath   File: SOAPMessageDispatch.java    License: GNU General Public License v2.0 5 votes vote down vote up
SOAPMessage toReturnValue(Packet response) {
    try {

        //not sure if this is the correct way to deal with this.
        if ( response ==null || response.getMessage() == null )
                 throw new WebServiceException(DispatchMessages.INVALID_RESPONSE());
        else
            return response.getMessage().readAsSOAPMessage();
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #28
Source Project: cxf   Author: apache   File: EndpointImpl.java    License: Apache License 2.0 5 votes vote down vote up
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz,
                                                            Element... referenceParameters) {
    if (W3CEndpointReference.class.isAssignableFrom(clazz)) {
        return clazz.cast(getEndpointReference(referenceParameters));
    }
    throw new WebServiceException(new org.apache.cxf.common.i18n.Message(
        "ENDPOINTREFERENCE_TYPE_NOT_SUPPORTED", LOG, clazz
        .getName()).toString());
}
 
Example #29
Source Project: TencentKona-8   Author: Tencent   File: XMLProviderArgumentBuilder.java    License: GNU General Public License v2.0 5 votes vote down vote up
static XMLProviderArgumentBuilder createBuilder(ProviderEndpointModel model, WSBinding binding) {
    if (model.mode == Service.Mode.PAYLOAD) {
        return new PayloadSource();
    } else {
        if(model.datatype==Source.class)
            return new PayloadSource();
        if(model.datatype== DataSource.class)
            return new DataSourceParameter(binding);
        throw new WebServiceException(ServerMessages.PROVIDER_INVALID_PARAMETER_TYPE(model.implClass,model.datatype));
    }
}
 
Example #30
Source Project: fido2   Author: StrongKey   File: SKFSClient.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void verifyJson(String responseJsonString){
    System.out.println(responseJsonString);
    try (JsonReader jsonReader = Json.createReader(new StringReader(responseJsonString))) {
        jsonReader.readObject();
    }
    catch(JsonParsingException ex){
        WebauthnTutorialLogger.logp(Level.SEVERE, CLASSNAME, "getResponseFromString",
                "WEBAUTHN-ERR-5001", ex.getLocalizedMessage());
        throw new WebServiceException(WebauthnTutorialLogger.getMessageProperty("WEBAUTHN-ERR-5001"));
    }
}