public STElement call() throws IOException { try { soapRequest.saveChanges(); if (debug) { System.out.print("********* REQUEST:"); Element e = new DOMReader().read(soapRequest.getSOAPPart()).getRootElement(); writer.write(e); System.out.println(); System.out.println("------------------"); } soapResponse = conn.call(soapRequest, wsdlURL); if (debug) { System.out.print("********* RESPONSE:"); Element e = new DOMReader().read(soapResponse.getSOAPPart()).getRootElement(); writer.write(e); System.out.println(); System.out.println("------------------"); } SOAPPart sp = soapResponse.getSOAPPart(); SOAPEnvelope env = sp.getEnvelope(); return new STElement(env.getBody()); } catch (SOAPException e) { e.printStackTrace(); return null; } }
public void handleMessage(SoapMessage message) { if (getInvoker(message).getProtocolHandlers().isEmpty()) { return; } if (getInvoker(message).isOutbound()) { if (!chainAlreadyContainsSAAJ(message)) { SAAJ_OUT.handleMessage(message); } message.getInterceptorChain().add(ending); } else { boolean isFault = handleMessageInternal(message); SOAPMessage msg = message.getContent(SOAPMessage.class); if (msg != null) { XMLStreamReader xmlReader = createXMLStreamReaderFromSOAPMessage(msg); message.setContent(XMLStreamReader.class, xmlReader); // replace headers try { SAAJInInterceptor.replaceHeaders(msg, message); } catch (SOAPException e) { e.printStackTrace(); } } if (isFault) { Endpoint ep = message.getExchange().get(Endpoint.class); message.getInterceptorChain().abort(); if (ep.getInFaultObserver() != null) { ep.getInFaultObserver().onMessage(message); } } } }
private SOAPFaultException createSOAPFaultException() { try { String namespace = "http://example.com/auctiontraq/schemas/doclit"; SOAPFactory soapFactory = SOAPFactory.newInstance(); Name name = soapFactory.createName("MySOAPFault", "ns0", namespace); Detail detail = soapFactory.createDetail(); DetailEntry entry = detail.addDetailEntry(name); entry.addNamespaceDeclaration("data", namespace); Name attrName1 = soapFactory.createName("myAttr", "data", namespace); entry.addAttribute(attrName1, "myvalue"); SOAPElement child = entry.addChildElement("message"); child.addTextNode("Server Exception"); Name name2 = soapFactory.createName("ExtraInformation", "ns0", namespace); DetailEntry entry2 = detail.addDetailEntry(name2); SOAPElement child2 = entry2.addChildElement("Reason"); child2.addTextNode("Address Not Found"); QName qname = new QName("http://schemas.xmlsoap.org/soap/envelope/", "server"); SOAPFault sf = soapFactory.createFault("SOAP Fault Exception:Address Not Found", qname); org.w3c.dom.Node n = sf.getOwnerDocument().importNode(detail, true); sf.appendChild(n); return new SOAPFaultException(sf); // printDetail(detail); // return new SOAPFaultException(qname, // "SOAP Fault Exception:Address Not Found", null, detail); } catch (SOAPException e) { e.printStackTrace(); // QName qname = new QName("http://schemas.xmlsoap.org/soap/envelope/", "client"); throw new WebServiceException("Exception While Creating SOAP Fault Exception", e); } }
/** 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; }
public void addNamespace(String prefix, String name) { try { SOAPPart sp = soapRequest.getSOAPPart(); SOAPEnvelope env = sp.getEnvelope(); env.addNamespaceDeclaration(prefix, name); } catch (SOAPException e) { e.printStackTrace(); } }
static { b.setBinary1( "fkldhafkdahfkdhfkhasdkfhldashfi9pweqryiweqyriqelhfklasdhfkldashflksdah".getBytes()); b.setBinary2( "epriepireroerupequreopruopweuqrowequrpoweqrupweqrweqrweuqrweqrwerwerer".getBytes()); try { messageFactory = MessageFactory.newInstance(); } catch (SOAPException e) { e.printStackTrace(); } }
private XMLStreamReader createXMLStreamReaderFromSOAPMessage(SOAPMessage soapMessage) { // responseMsg.setContent(SOAPMessage.class, soapMessage); XMLStreamReader xmlReader = null; try { DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody()); xmlReader = StaxUtils.createXMLStreamReader(bodySource); xmlReader.nextTag(); xmlReader.nextTag(); // move past body tag } catch (SOAPException e) { e.printStackTrace(); } catch (XMLStreamException e) { e.printStackTrace(); } return xmlReader; }
public static void main(String[] args) { new LinkedHashMap() { @Override protected boolean removeEldestEntry(java.util.Map.Entry eldest) { // TODO Auto-generated method stub return super.removeEldestEntry(eldest); } }; for (int i = 33; i < 34; i++) { try { Neolane4J myNeolane = Neolane4J.getInstance(); myNeolane.select("ecp", "results", new String[] {"id", "source", "datetime", "link"}); } catch (SOAPException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }