本文整理汇总了Java中javax.xml.ws.ProtocolException类的典型用法代码示例。如果您正苦于以下问题:Java ProtocolException类的具体用法?Java ProtocolException怎么用?Java ProtocolException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProtocolException类属于javax.xml.ws包,在下文中一共展示了ProtocolException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertFaultMessage
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
/**
* Replace the message in the given message context with a
* fault message. If the context already contains a fault
* message, then return without changing it.
*
* <p>This method should only be called during a request,
* because during a response an exception from a handler
* is dispatched rather than replacing the message with
* a fault. So this method can use the MESSAGE_OUTBOUND_PROPERTY
* to determine whether it is being called on the client
* or the server side. If this changes in the spec, then
* something else will need to be passed to the method
* to determine whether the fault code is client or server.
*/
final void insertFaultMessage(C context,
ProtocolException exception) {
try {
if(!context.getPacketMessage().isFault()) {
Message faultMessage = Messages.create(binding.getSOAPVersion(),
exception,determineFaultCode(binding.getSOAPVersion()));
context.setPacketMessage(faultMessage);
}
} catch (Exception e) {
// severe since this is from runtime and not handler
logger.log(Level.SEVERE,
"exception while creating fault message in handler chain", e);
throw new RuntimeException(e);
}
}
示例2: createResponse
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
public Message createResponse(JavaCallInfo call) {
Message responseMessage;
if (call.getException() == null) {
responseMessage = isOneWay ? null : createResponseMessage(call.getParameters(), call.getReturnValue());
} else {
Throwable e = call.getException();
Throwable serviceException = getServiceException(e);
if (e instanceof InvocationTargetException || serviceException != null) {
// Throwable cause = e.getCause();
//if (!(cause instanceof RuntimeException) && cause instanceof Exception) {
if (serviceException != null) {
// Service specific exception
LOGGER.log(Level.FINE, serviceException.getMessage(), serviceException);
responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion,
javaMethodModel.getCheckedException(serviceException.getClass()), serviceException);
} else {
Throwable cause = e.getCause();
if (cause instanceof ProtocolException) {
// Application code may be throwing it intentionally
LOGGER.log(Level.FINE, cause.getMessage(), cause);
} else {
// Probably some bug in application code
LOGGER.log(Level.SEVERE, cause.getMessage(), cause);
}
responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, cause);
}
} else if (e instanceof DispatchException) {
responseMessage = ((DispatchException)e).fault;
} else {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
}
// return req.createServerResponse(responseMessage, req.endpoint.getPort(), javaMethodModel.getOwner(), req.endpoint.getBinding());
return responseMessage;
}
示例3: crawl
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
/**
* Pulls the {@link ResponseHeader} for {@code uri}.
*/
public ResponseHeader crawl(URL uri) {
HttpURLConnection.setFollowRedirects(false);
HttpURLConnection conn = null;
try {
conn = (HttpURLConnection) uri.openConnection();
conn.setRequestMethod("HEAD");
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new IOException("Got unexpected response code: " + conn.getResponseCode());
}
return new ResponseHeader(conn.getContentLengthLong(), conn.getHeaderField("ETag"));
} catch (IOException | ProtocolException e) {
throw new RuntimeException(e);
} finally {
if(conn != null) {
conn.disconnect();
}
}
}
示例4: getFaultResponse
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
/**
* Returns the fault that is contained within the MessageContext for an invocation. If no fault
* exists, null will be returned.
*
* @param msgCtx
* @return
*/
public static WebServiceException getFaultResponse(MessageContext msgCtx) {
try {
Message msg = msgCtx.getMessage();
if (msg != null && msg.isFault()) {
//XMLFault fault = msg.getXMLFault();
// 4.3.2 conformance bullet 1 requires a ProtocolException here
ProtocolException pe =
MethodMarshallerUtils.createSystemException(msg.getXMLFault(), msg);
return pe;
} else if (msgCtx.getLocalException() != null) {
// use the factory, it'll throw the right thing:
return ExceptionFactory.makeWebServiceException(msgCtx.getLocalException());
}
} finally {
// Free the incoming input stream
try {
msgCtx.freeInputStream();
} catch (IOException ioe) {
return ExceptionFactory.makeWebServiceException(ioe);
}
}
return null;
}
示例5: makeProtocolException
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
/**
* Create a ProtocolException using the information from a Throwable and message
*
* @param message
* @param throwable
* @return ProtocolException
*/
public static ProtocolException makeProtocolException(String message, Throwable throwable) {
try {
// See if there is already a ProtocolException
ProtocolException e =
(ProtocolException)findException(throwable, ProtocolException.class);
if (e == null) {
e = createProtocolException(message, throwable);
}
return e;
} catch (RuntimeException re) {
// TODO
// This is not a good situation, an exception occurred while building the exception.
// This should never occur! For now log the problem and rethrow...we may revisit this later
if (log.isDebugEnabled()) {
log.debug(Messages.getMessage("exceptionDuringExceptionFlow"), re);
}
throw re;
}
}
示例6: handleMessage
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
public boolean handleMessage(SOAPMessageContext messagecontext) {
Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outbound) {
// this is the first client outbound handler hit
Map<QName, List<String>> requestHeaders = (Map<QName, List<String>>)messagecontext.get(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
// this should generate an exception. We have protection built in to prevent using both
// the SOAPHeadersAdapter and SAAJ in the same handler method
List<String> list1 = requestHeaders.get(TestHeaders.ACOH1_HEADER_QNAME);
try {
messagecontext.getMessage().getSOAPHeader();
} catch (SOAPException e) {
throw new ProtocolException(e);
}
}
else { // client inbound response
}
return true;
}
示例7: insertFaultMessage
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
final void insertFaultMessage(C context,
ProtocolException exception) {
if(exception instanceof HTTPException) {
context.put(MessageContext.HTTP_RESPONSE_CODE,((HTTPException)exception).getStatusCode());
}
if (context != null) {
// non-soap case
context.setPacketMessage(Messages.createEmpty(binding.getSOAPVersion()));
}
}
示例8: handleMessage
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean outboundProperty = (Boolean) context
.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (false == outboundProperty) {
return true;
}
try {
handleOutboundMessage(context);
} catch (Exception e) {
LOG.error("outbound exception: " + e.getMessage(), e);
throw new ProtocolException(e);
}
return true;
}
示例9: handleMessage
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outboundProperty) {
return true;
}
try {
handleInboundMessage(context);
} catch (Exception e) {
LOGGER.error("error: " + e.getMessage(), e);
throw new ProtocolException(e);
}
return true;
}
示例10: handleMessage
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean outboundProperty = (Boolean) context
.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (false == outboundProperty) {
try {
handleInboundMessage(context);
} catch (Exception e) {
throw new ProtocolException(e);
}
}
return true;
}
示例11: handleMessage
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (true == outboundProperty.booleanValue()) {
try {
handleOutboundMessage(context);
} catch (Exception e) {
LOGGER.error("outbound exception: " + e.getMessage(), e);
throw new ProtocolException(e);
}
}
return true;
}
示例12: handleMessage
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (false == outboundProperty.booleanValue()) {
try {
handleInboundMessage(context);
} catch (Exception e) {
throw new ProtocolException(e);
}
}
return true;
}
示例13: testHandleMessage_protocolex_true2
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
public void testHandleMessage_protocolex_true2() {
// reset result
result = "";
soaphandler1_MessageResultDesired = ResultDesired.TRUE;
soaphandler1_FaultResultDesired = ResultDesired.TRUE;
soaphandler2_MessageResultDesired = ResultDesired.TRUE;
soaphandler2_FaultResultDesired = ResultDesired.TRUE;
logicalhandler1_MessageResultDesired = ResultDesired.PROTOCOL_EXCEPTION;
logicalhandler1_FaultResultDesired = ResultDesired.TRUE;
logicalhandler2_MessageResultDesired = ResultDesired.TRUE;
logicalhandler2_FaultResultDesired = ResultDesired.TRUE;
HandlerChainProcessor processor = new HandlerChainProcessor(handlers, Protocol.soap11);
MessageContext mc1 = new MessageContext();
mc1.setMEPContext(new MEPContext(mc1));
Exception e = null;
try {
processor.processChain(mc1.getMEPContext(),
HandlerChainProcessor.Direction.IN,
HandlerChainProcessor.MEP.REQUEST,
false);
} catch (ProtocolException pe) {
e = pe;
}
assertNull(e);
// no handleFault calls
assertEquals("S2m:S1m:L1m:L1c:S1c:S2c:", result);
}
示例14: testHandleMessage_protocolex_protocolex
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
public void testHandleMessage_protocolex_protocolex() {
// reset result
result = "";
// we want one false response:
soaphandler1_MessageResultDesired = ResultDesired.TRUE;
soaphandler1_FaultResultDesired = ResultDesired.PROTOCOL_EXCEPTION;
soaphandler2_MessageResultDesired = ResultDesired.TRUE;
soaphandler2_FaultResultDesired = ResultDesired.TRUE;
logicalhandler1_MessageResultDesired = ResultDesired.PROTOCOL_EXCEPTION;
logicalhandler1_FaultResultDesired = ResultDesired.TRUE;
logicalhandler2_MessageResultDesired = ResultDesired.TRUE;
logicalhandler2_FaultResultDesired = ResultDesired.TRUE;
HandlerChainProcessor processor = new HandlerChainProcessor(handlers, Protocol.soap11);
MessageContext mc1 = new MessageContext();
mc1.setMEPContext(new MEPContext(mc1));
Exception e = null;
try {
// handleFault processing, but notice S2f does not get called, and we get an exception
processor.processChain(mc1.getMEPContext(),
HandlerChainProcessor.Direction.IN,
HandlerChainProcessor.MEP.REQUEST,
true);
} catch (ProtocolException pe) {
e = pe;
}
assertNotNull(e);
assertEquals("S2m:S1m:L1m:S1f:L1c:S1c:S2c:", result);
}
示例15: testHandleFault_protocolex
import javax.xml.ws.ProtocolException; //导入依赖的package包/类
public void testHandleFault_protocolex() {
// reset result
result = "";
// we want one false response:
soaphandler1_MessageResultDesired = ResultDesired.TRUE;
soaphandler1_FaultResultDesired = ResultDesired.TRUE;
soaphandler2_MessageResultDesired = ResultDesired.TRUE;
soaphandler2_FaultResultDesired = ResultDesired.TRUE;
logicalhandler1_MessageResultDesired = ResultDesired.TRUE;
logicalhandler1_FaultResultDesired = ResultDesired.PROTOCOL_EXCEPTION;
logicalhandler2_MessageResultDesired = ResultDesired.TRUE;
logicalhandler2_FaultResultDesired = ResultDesired.TRUE;
HandlerChainProcessor processor = new HandlerChainProcessor(handlers, Protocol.soap11);
MessageContext mc1 = new MessageContext();
mc1.setMEPContext(new MEPContext(mc1));
Exception e = null;
try {
// notice all handlers are closed in this scenario, and we get an exception
processor.processFault(mc1.getMEPContext(), HandlerChainProcessor.Direction.IN);
} catch (ProtocolException pe) {
e = pe;
}
assertNotNull(e);
assertEquals("S2f:S1f:L1f:S2c:S1c:L1c:L2c:", result);
}