Java Code Examples for javax.xml.soap.SOAPException#printStackTrace()

The following examples show how to use javax.xml.soap.SOAPException#printStackTrace() . 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: JPlagClientAccessHandler.java    From jplag with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds an "Access" element to the SOAP header
 */
public boolean handleRequest(MessageContext msgct) {
	if (msgct instanceof SOAPMessageContext) {
		SOAPMessageContext smsgct = (SOAPMessageContext) msgct;
		try {
			SOAPMessage msg = smsgct.getMessage();
			SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
			SOAPHeader header = msg.getSOAPHeader();

			if (header == null)
				header = envelope.addHeader(); // add an header if non exists

			SOAPHeaderElement accessElement = header.addHeaderElement(envelope.createName("Access", "ns0", JPLAG_TYPES_NS));
			SOAPElement usernameelem = accessElement.addChildElement("username");
			usernameelem.addTextNode(username);
			SOAPElement passwordelem = accessElement.addChildElement("password");
			passwordelem.addTextNode(password);
			SOAPElement compatelem = accessElement.addChildElement("compatLevel");
			compatelem.addTextNode(compatibilityLevel + "");
		} catch (SOAPException x) {
			System.out.println("Unable to create access SOAP header!");
			x.printStackTrace();
		}
	}
	return true;
}
 
Example 2
Source File: SoapRequestBean.java    From openxds with Apache License 2.0 6 votes vote down vote up
public SOAPMessage onMessage(SOAPMessage msg){
    //handles the response back from the registry
    PrintStream orig = System.out;
    
    try {
        SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
        Name response = env.createName("response");
        env.getBody().getChildElements(response);
        
    } catch (SOAPException ex) {
        ByteArrayOutputStream logarray = new ByteArrayOutputStream();
        ex.printStackTrace(writeErrorlog(logarray));
        logstring = logarray.toString();
        setlogmsg(logstring);  
    }
    
    return msg;
}
 
Example 3
Source File: MailTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
void addSoapAttachement() {
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();
        AttachmentPart a = message.createAttachmentPart();
        a.setContentType("binary/octet-stream");
        message.addAttachmentPart(a);
    } catch (SOAPException e) {
        e.printStackTrace();
    }
}
 
Example 4
Source File: JPlagServerAccessHandler.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Manually builds up a JPlagException SOAP message and replaces the
 * original one with it
 */
public void replaceByJPlagException(SOAPMessageContext smsg, String desc, String rep) {
	try {
		SOAPMessage msg = smsg.getMessage();
		SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();

		/*
		 * Remove old header andy body
		 */

		SOAPHeader oldheader = envelope.getHeader();
		if (oldheader != null)
			oldheader.detachNode();
		SOAPBody oldbody = envelope.getBody();
		if (oldbody != null)
			oldbody.detachNode();

		SOAPBody sb = envelope.addBody();
		SOAPFault sf = sb.addFault(envelope.createName("Server", "env", SOAPConstants.URI_NS_SOAP_ENVELOPE),
				"jplagWebService.server.JPlagException");
		Detail detail = sf.addDetail();
		DetailEntry de = detail.addDetailEntry(envelope.createName("JPlagException", "ns0", JPLAG_WEBSERVICE_BASE_URL + "types"));

		SOAPElement e = de.addChildElement("exceptionType");
		e.addTextNode("accessException");

		e = de.addChildElement("description");
		e.addTextNode(desc);

		e = de.addChildElement("repair");
		e.addTextNode(rep);
	} catch (SOAPException x) {
		x.printStackTrace();
	}
}
 
Example 5
Source File: JPlagServerAccessHandler.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Extracts the username out of the header of a SOAP message
 */
public static String extractUsername(SOAPMessageContext smsg) {
	try {
		SOAPHeader header = smsg.getMessage().getSOAPHeader();
		if (header != null) {
			@SuppressWarnings("unchecked")
			Iterator<SOAPHeaderElement> headers = header.examineAllHeaderElements();
			while (headers.hasNext()) {
				SOAPHeaderElement he = headers.next();

				if (he.getElementName().getLocalName().equals("Access")) {
					@SuppressWarnings("unchecked")
					Iterator<SOAPElement> elements = he.getChildElements();
					while (elements.hasNext()) {
						SOAPElement e = elements.next();
						String name = e.getElementName().getLocalName();
						if (name.equals("username"))
							return e.getValue();
					}
				}
			}
		}
	} catch (SOAPException x) {
		x.printStackTrace();
	}
	return null;
}
 
Example 6
Source File: JPlagClientAccessHandler.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds an "Access" element to the SOAP header
 */
public boolean handleRequest(MessageContext msgct) {
	if(msgct instanceof SOAPMessageContext) {
		SOAPMessageContext smsgct=(SOAPMessageContext) msgct;
		try	{
			SOAPMessage msg=smsgct.getMessage();
			SOAPEnvelope envelope=msg.getSOAPPart().getEnvelope();
			SOAPHeader header=msg.getSOAPHeader();
			
			if(header==null)
				header=envelope.addHeader(); // add an header if non exists
			
			SOAPHeaderElement accessElement=header.addHeaderElement(
					envelope.createName("Access","ns0",
							"http://www.ipd.uni-karlsruhe.de/jplag/types"));
			SOAPElement usernameelem=accessElement.addChildElement(
                       "username");
			usernameelem.addTextNode(username);
			SOAPElement passwordelem=accessElement.addChildElement(
                       "password");
			passwordelem.addTextNode(password);
               SOAPElement compatelem=accessElement.addChildElement(
                       "compatLevel");
               compatelem.addTextNode(compatibilityLevel+"");
		} catch (SOAPException x) {
			System.out.println("Unable to create access SOAP header!");
			x.printStackTrace();
		}
	}
	return true;
}
 
Example 7
Source File: MailTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
void addSoapAttachement() {
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();
        AttachmentPart a = message.createAttachmentPart();
        a.setContentType("binary/octet-stream");
        message.addAttachmentPart(a);
    } catch (SOAPException e) {
        e.printStackTrace();
    }
}
 
Example 8
Source File: MailTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void addSoapAttachement() {
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();
        AttachmentPart a = message.createAttachmentPart();
        a.setContentType("binary/octet-stream");
        message.addAttachmentPart(a);
    } catch (SOAPException e) {
        e.printStackTrace();
    }
}
 
Example 9
Source File: VOConverter.java    From development with Apache License 2.0 5 votes vote down vote up
/**
 * @param context
 * @param details
 * @param parameterName
 */
private void adaptSOAPMessageForVO(ConverterContext context,
        List<ModificationDetail> details, String parameterName) {
    for (ModificationDetail detail : details) {
        IAdapter adapter = AdapterFactory.getAdapter(detail.getType());
        detail.getVariable().setVariableName(parameterName);
        try {
            adapter.exec(context.getSoapContext(), detail);
        } catch (SOAPException e) {
            e.printStackTrace();
        }
    }
}
 
Example 10
Source File: MailTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
void addSoapAttachement() {
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();
        AttachmentPart a = message.createAttachmentPart();
        a.setContentType("binary/octet-stream");
        message.addAttachmentPart(a);
    } catch (SOAPException e) {
        e.printStackTrace();
    }
}
 
Example 11
Source File: ArcherBasicRestConnection.java    From FortifyBugTrackerUtility with MIT License 5 votes vote down vote up
public void writeTo(SOAPMessage soapMessage, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException {
    try {
        soapMessage.writeTo(outputStream);
    } catch (SOAPException e) {
        e.printStackTrace();
    }
}
 
Example 12
Source File: ArcherBasicRestConnection.java    From FortifyBugTrackerUtility with MIT License 5 votes vote down vote up
public SOAPMessage readFrom(Class<SOAPMessage> soapEnvelopeClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> stringStringMultivaluedMap, InputStream inputStream) throws IOException, WebApplicationException {
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        StreamSource messageSource = new StreamSource(inputStream);
        SOAPMessage message = messageFactory.createMessage();
        SOAPPart soapPart = message.getSOAPPart();
        soapPart.setContent(messageSource);
        return message;
    } catch (SOAPException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 13
Source File: MailTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
void addSoapAttachement() {
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();
        AttachmentPart a = message.createAttachmentPart();
        a.setContentType("binary/octet-stream");
        message.addAttachmentPart(a);
    } catch (SOAPException e) {
        e.printStackTrace();
    }
}
 
Example 14
Source File: MailTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void addSoapAttachement() {
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();
        AttachmentPart a = message.createAttachmentPart();
        a.setContentType("binary/octet-stream");
        message.addAttachmentPart(a);
    } catch (SOAPException e) {
        e.printStackTrace();
    }
}
 
Example 15
Source File: MailTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void addSoapAttachement() {
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();
        AttachmentPart a = message.createAttachmentPart();
        a.setContentType("binary/octet-stream");
        message.addAttachmentPart(a);
    } catch (SOAPException e) {
        e.printStackTrace();
    }
}
 
Example 16
Source File: MailTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void addSoapAttachement() {
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();
        AttachmentPart a = message.createAttachmentPart();
        a.setContentType("binary/octet-stream");
        message.addAttachmentPart(a);
    } catch (SOAPException e) {
        e.printStackTrace();
    }
}
 
Example 17
Source File: MailTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
void addSoapAttachement() {
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();
        AttachmentPart a = message.createAttachmentPart();
        a.setContentType("binary/octet-stream");
        message.addAttachmentPart(a);
    } catch (SOAPException e) {
        e.printStackTrace();
    }
}
 
Example 18
Source File: MailTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void addSoapAttachement() {
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();
        AttachmentPart a = message.createAttachmentPart();
        a.setContentType("binary/octet-stream");
        message.addAttachmentPart(a);
    } catch (SOAPException e) {
        e.printStackTrace();
    }
}
 
Example 19
Source File: MailTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void addSoapAttachement() {
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();
        AttachmentPart a = message.createAttachmentPart();
        a.setContentType("binary/octet-stream");
        message.addAttachmentPart(a);
    } catch (SOAPException e) {
        e.printStackTrace();
    }
}
 
Example 20
Source File: JPlagServerAccessHandler.java    From jplag with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Checks whether the SOAP message contains a valid Access element (correct
 * username + password) and whether the account may still be used
 */
public boolean handleRequest(MessageContext context) {
	String username = null;
	String password = null;
	int compatLevel = 0;
	if (context instanceof SOAPMessageContext) {
		SOAPMessageContext smsg = (SOAPMessageContext) context;

		/*
		 * Iterator iter = context.getPropertyNames();
		 * System.out.println("Context properties:"); while(iter.hasNext())
		 * { String propname = (String) iter.next();
		 * System.out.println(propname + " = " +
		 * context.getProperty(propname).toString()); }
		 * 
		 * HttpServletRequest request = (HttpServletRequest)
		 * context.getProperty(
		 * "com.sun.xml.rpc.server.http.HttpServletRequest");
		 * System.out.println("Client IP: " + request.getRemoteAddr());
		 */

		try {
			SOAPHeader header = smsg.getMessage().getSOAPHeader();
			if (header != null) {
				@SuppressWarnings("unchecked")
				Iterator<SOAPHeaderElement> headers = header.examineAllHeaderElements();
				while (headers.hasNext()) {
					SOAPHeaderElement he = headers.next();

					if (he.getElementName().getLocalName().equals("Access")) {
						@SuppressWarnings("unchecked")
						Iterator<SOAPElement> elements = he.getChildElements();
						while (elements.hasNext()) {
							SOAPElement e = elements.next();
							String name = e.getElementName().getLocalName();
							if (name.equals("username"))
								username = e.getValue();
							else if (name.equals("password"))
								password = e.getValue();
							else if (name.equals("compatLevel")) {
								try {
									compatLevel = Integer.parseInt(e.getValue());
								} catch (NumberFormatException ex) {
									compatLevel = -1;
								}
							}
						}
					}
				}
				if (compatLevel < compatibilityLevel) {
					replaceByJPlagException(smsg, "Client outdated!", "Please update your client " + "to compatibility level "
							+ compatibilityLevel + ".");
					return false;
				}
				if (username != null && password != null) {
					int state = JPlagCentral.getInstance().getUserAdmin().getLoginState(username, password);
					if ((state & UserAdmin.MASK_EXPIRED) != 0) {
						replaceByJPlagException(smsg, "Access denied!", "Your account has " + "expired! Please contact the JPlag "
								+ "administrator to reactivate it!");
						return false;
					} else if ((state & UserAdmin.MASK_DEACTIVATED) != 0) {
						replaceByJPlagException(smsg, "Access denied!", "Your account has " + "been deactivated! Please contact the "
								+ "JPlag administrator to reactivate it!");
						return false;
					} else if (state != UserAdmin.USER_INVALID)
						return true;
				}
			} else {
				System.out.println("No header available!");
				replaceByJPlagException(smsg, "Access denied!", "The SOAP message doesn't contain an access header!");
				return false;
			}
		} catch (SOAPException x) {
			x.printStackTrace();
		}
		System.out.println("[" + new Date() + "] Access denied for user \"" + username + "\"!");

		replaceByJPlagException(smsg, "Access denied!", "Check your username and password!");
		return false;
	}
	System.out.println("Not a SOAP message context!!!");
	return false;
}