/** * Returns a string containing info about all the SOAP attachments. * * @param soapMessage SOAP message * @return String containing attachments info */ public static String getAttachmentsInfo(SOAPMessage soapMessage) { try { int numOfAttachments = soapMessage.countAttachments(); Iterator attachments = soapMessage.getAttachments(); StringBuilder buf = new StringBuilder("Number of attachments: "); buf.append(numOfAttachments); int count = 1; while (attachments.hasNext()) { AttachmentPart attachment = (AttachmentPart) attachments.next(); buf.append(" | #").append(count); buf.append(" | Content Location: ").append(attachment.getContentLocation()); buf.append(" | Content Id: ").append(attachment.getContentId()); buf.append(" | Content Size: ").append(attachment.getSize()); buf.append(" | Content Type: ").append(attachment.getContentType()); count++; } return buf.toString(); } catch (SOAPException e) { LOGGER.error(e.getMessage(), e); return ""; } }
protected void addNode(org.w3c.dom.Node newElement) throws SOAPException { insertBefore(soapDocument.getDomNode(newElement), null); if (getOwnerDocument() instanceof DocumentFragment) return; if (newElement instanceof ElementImpl) { ElementImpl element = (ElementImpl) newElement; QName elementName = element.getElementQName(); if (!"".equals(elementName.getNamespaceURI())) { element.ensureNamespaceIsDeclared( elementName.getPrefix(), elementName.getNamespaceURI()); } } }
/** * Client list with 2 members (MEMBER, SUBSYSTEM) * * @throws XRd4JException * @throws SOAPException */ public void test1() throws XRd4JException, SOAPException { String soapString = "<?xml version=\"1.0\"?><xrd:clientList xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\" xmlns:id=\"http://x-road.eu/xsd/identifiers\"><xrd:member><xrd:id id:objectType=\"MEMBER\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>12345</id:memberCode></xrd:id><xrd:name>Test org</xrd:name></xrd:member><xrd:member><xrd:id id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI-DEV</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>54321</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:id><xrd:name>Another org</xrd:name></xrd:member></xrd:clientList>"; List<ConsumerMember> list = new ListClientsResponseDeserializer().deserializeConsumerList(soapString); assertEquals("FI", list.get(0).getXRoadInstance()); assertEquals("GOV", list.get(0).getMemberClass()); assertEquals("12345", list.get(0).getMemberCode()); assertEquals(null, list.get(0).getSubsystemCode()); assertEquals(ObjectType.MEMBER, list.get(0).getObjectType()); assertEquals("FI-DEV", list.get(1).getXRoadInstance()); assertEquals("COM", list.get(1).getMemberClass()); assertEquals("54321", list.get(1).getMemberCode()); assertEquals("subsystem", list.get(1).getSubsystemCode()); assertEquals(ObjectType.SUBSYSTEM, list.get(1).getObjectType()); }
/** * Subsystem level service call. Use namespace prefix in request's and * response's child elements. * @throws XRd4JException * @throws SOAPException */ public void test7() throws XRd4JException, SOAPException { String requestStr = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>7.5</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getRandom xmlns:ns1=\"http://consumer.x-road.ee\"><ns1:request><ns1:data>Request data</ns1:data></ns1:request></ns1:getRandom></SOAP-ENV:Body></SOAP-ENV:Envelope>"; String correctResponse = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>7.5</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getRandomResponse xmlns:ns1=\"http://consumer.x-road.ee\"><ns1:request><ns1:data>Request data</ns1:data></ns1:request><ns1:response><ns1:data>Response data</ns1:data></ns1:response></ns1:getRandomResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>"; ConsumerMember consumer = new ConsumerMember("FI", "GOV", "MEMBER1", "subsystem"); ProducerMember producer = new ProducerMember("FI", "COM", "MEMBER2", "subsystem", "getRandom", "v1"); ServiceRequest<String> request = new ServiceRequest<String>(consumer, producer, "1234567890"); request.setUserId("EE1234567890"); request.setProtocolVersion("7.5"); request.setRequestData("Request data"); request.setSoapMessage(SOAPHelper.toSOAP(requestStr)); request.getProducer().setNamespacePrefix("ns1"); request.getProducer().setNamespaceUrl("http://consumer.x-road.ee"); ServiceResponse<String, String> response = new ServiceResponse<String, String>(request.getConsumer(), request.getProducer(), request.getId()); response.setResponseData("Response data"); ServiceResponseSerializer serializer = new ServiceResponseSerializerImpl2(); SOAPMessage msg = serializer.serialize(response, request); assertEquals(correctResponse, SOAPHelper.toString(msg)); }
/** * This should be used only in ServerMUPipe * * @param notUnderstoodHeaders * @return Message representing a SOAPFault * In SOAP 1.1, notUnderstoodHeaders are added in the fault Detail * in SOAP 1.2, notUnderstoodHeaders are added as the SOAP Headers */ final Message createMUSOAPFaultMessage(Set<QName> notUnderstoodHeaders) { try { String faultString = MUST_UNDERSTAND_FAULT_MESSAGE_STRING; if (soapVersion == SOAP_11) { faultString = "MustUnderstand headers:" + notUnderstoodHeaders + " are not understood"; } Message muFaultMessage = SOAPFaultBuilder.createSOAPFaultMessage( soapVersion,faultString,soapVersion.faultCodeMustUnderstand); if (soapVersion == SOAP_12) { addHeader(muFaultMessage, notUnderstoodHeaders); } return muFaultMessage; } catch (SOAPException e) { throw new WebServiceException(e); } }
/** * Subsystem level service call. No NS prefix. * * @throws XRd4JException * @throws SOAPException */ public void test1WithoutWrappers() throws XRd4JException, SOAPException { String correctRequest = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.0</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><getRandom xmlns=\"http://consumer.x-road.ee\"><data>1234567890</data></getRandom></SOAP-ENV:Body></SOAP-ENV:Envelope>"; ConsumerMember consumer = new ConsumerMember("FI", "GOV", "MEMBER1", "subsystem"); ProducerMember producer = new ProducerMember("FI", "COM", "MEMBER2", "subsystem", "getRandom", "v1"); producer.setNamespacePrefix(""); producer.setNamespaceUrl("http://consumer.x-road.ee"); ServiceRequest<String> request = new ServiceRequest<String>(consumer, producer, "1234567890"); request.setUserId("EE1234567890"); request.setRequestData("1234567890"); request.setProcessingWrappers(false); ServiceRequestSerializer serializer = new TestRequestSerializer(); SOAPMessage msg = serializer.serialize(request); assertEquals(correctRequest, SOAPHelper.toString(msg)); }
/** * Subsystem level service call. No NS on request. NS prefix on response. * Request element with no children * @throws XRd4JException * @throws SOAPException */ public void test11() throws XRd4JException, SOAPException { String requestStr = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.0</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getRandom xmlns:ns1=\"http://consumer.x-road.ee\"><request></request></ns1:getRandom></SOAP-ENV:Body></SOAP-ENV:Envelope>"; String correctResponse = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.0</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><xxprod:getRandomResponse xmlns:xxprod=\"http://foobar.x-road.ee/producer\"><xxprod:request/><xxprod:response><xxprod:data>Response data</xxprod:data></xxprod:response></xxprod:getRandomResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>"; ConsumerMember consumer = new ConsumerMember("FI", "GOV", "MEMBER1", "subsystem"); ProducerMember producer = new ProducerMember("FI", "COM", "MEMBER2", "subsystem", "getRandom", "v1"); ServiceRequest<String> request = new ServiceRequest<String>(consumer, producer, "1234567890"); request.setUserId("EE1234567890"); request.setRequestData("Request data"); request.setSoapMessage(SOAPHelper.toSOAP(requestStr)); request.getProducer().setNamespacePrefix("xxprod"); request.getProducer().setNamespaceUrl("http://foobar.x-road.ee/producer"); ServiceResponse<String, String> response = new ServiceResponse<String, String>(request.getConsumer(), request.getProducer(), request.getId()); response.setResponseData("Response data"); ServiceResponseSerializer serializer = new ServiceResponseSerializerImpl(); SOAPMessage msg = serializer.serialize(response, request); assertEquals(correctResponse, SOAPHelper.toString(msg)); }
@Override protected Envelope createEnvelopeFromSource() throws SOAPException { // Record the presence of xml declaration before the envelope gets // created. XMLDeclarationParser parser = lookForXmlDecl(); Source tmp = source; source = null; EnvelopeImpl envelope = (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this); if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) { log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1"); throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message"); } if (parser != null && !omitXmlDecl) { envelope.setOmitXmlDecl("no"); envelope.setXmlDecl(parser.getXmlDeclaration()); envelope.setCharsetEncoding(parser.getEncoding()); } return envelope; }
@Override protected void checkIfStandardFaultCode(String faultCode, String uri) throws SOAPException { QName qname = new QName(uri, faultCode); if (SOAPConstants.SOAP_DATAENCODINGUNKNOWN_FAULT.equals(qname) || SOAPConstants.SOAP_MUSTUNDERSTAND_FAULT.equals(qname) || SOAPConstants.SOAP_RECEIVER_FAULT.equals(qname) || SOAPConstants.SOAP_SENDER_FAULT.equals(qname) || SOAPConstants.SOAP_VERSIONMISMATCH_FAULT.equals(qname)) return; log.log( Level.SEVERE, "SAAJ0435.ver1_2.code.not.standard", qname); throw new SOAPExceptionImpl(qname + " is not a standard Code value"); }
/** * Subsystem level service call. Producer namespace and prefix already set * by the serializer implementation. * * @throws XRd4JException * @throws SOAPException */ public void test9() throws XRd4JException, SOAPException { String correctRequest = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.0</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getRandom xmlns:ns1=\"http://consumer.x-road.ee\"><ns1:request><ns1:data>1234567890</ns1:data></ns1:request></ns1:getRandom></SOAP-ENV:Body></SOAP-ENV:Envelope>"; ConsumerMember consumer = new ConsumerMember("FI", "GOV", "MEMBER1", "subsystem"); ProducerMember producer = new ProducerMember("FI", "COM", "MEMBER2", "subsystem", "getRandom", "v1"); producer.setNamespacePrefix("ns1"); producer.setNamespaceUrl("http://consumer.x-road.ee"); ServiceRequest<String> request = new ServiceRequest<String>(consumer, producer, "1234567890"); request.setUserId("EE1234567890"); request.setRequestData("1234567890"); ServiceRequestSerializer serializer = new TestRequestSerializer1(); SOAPMessage msg = serializer.serialize(request); assertEquals(correctRequest, SOAPHelper.toString(msg)); }
/** * SOAP Fault with detail null. * @throws XRd4JException * @throws SOAPException */ public void testSOAPFault3() throws XRd4JException, SOAPException { String requestStr = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.0</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getRandom xmlns:ns1=\"http://consumer.x-road.ee\"><request><data>Request data</data></request></ns1:getRandom></SOAP-ENV:Body></SOAP-ENV:Envelope>"; String correctResponse = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"><SOAP-ENV:Header/><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>Fault code</faultcode><faultstring>Fault string</faultstring><faultactor>Fault actor</faultactor></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>"; ConsumerMember consumer = new ConsumerMember("FI", "GOV", "MEMBER1", "subsystem"); ProducerMember producer = new ProducerMember("FI", "COM", "MEMBER2", "subsystem", "getRandom", "v1"); ServiceRequest<String> request = new ServiceRequest<String>(consumer, producer, "1234567890"); request.setUserId("EE1234567890"); request.setRequestData("Request data"); request.setSoapMessage(SOAPHelper.toSOAP(requestStr)); request.getProducer().setNamespacePrefix("xxprod"); request.getProducer().setNamespaceUrl("http://foobar.x-road.ee/producer"); ServiceResponse<String, String> response = new ServiceResponse<String, String>(); response.setResponseData("Response data"); ErrorMessage errorMsg = new ErrorMessage("Fault code", "Fault string", "Fault actor", null); response.setErrorMessage(errorMsg); ServiceResponseSerializer serializer = new ServiceResponseSerializerImpl(); SOAPMessage msg = serializer.serialize(response, request); assertEquals(correctResponse, SOAPHelper.toString(msg)); }
private String getXmlPayload(SOAPMessage rawSoapResponse) throws IOException, SOAPException { String prefix = rawSoapResponse.getSOAPPart().getEnvelope().getPrefix(); String rawResponse = convertToString(rawSoapResponse); String xmlMessage = ""; String beginSoapTag = "<" + prefix + ":Envelope"; String endSoapTag = "</" + prefix + ":Envelope>"; int start = rawResponse.indexOf(beginSoapTag); int end = rawResponse.lastIndexOf(endSoapTag) + prefix.length() + LENGTH_XML_ENCLOSING_TAG; if (start >= 0 || end > 0) { xmlMessage = rawResponse.substring(start, end); LOGGER.debug("xmlMessage = " + xmlMessage); } else { throw new IllegalArgumentException("Can't parse soap message " + rawResponse); } return xmlMessage; }
@Override public void setEncodingStyle(String encodingStyle) throws SOAPException { if (!"".equals(encodingStyle)) { try { new URI(encodingStyle); } catch (URISyntaxException m) { log.log( Level.SEVERE, "SAAJ0105.impl.encoding.style.mustbe.valid.URI", new String[] { encodingStyle }); throw new IllegalArgumentException( "Encoding style (" + encodingStyle + ") should be a valid URI"); } } encodingStyleAttribute.setValue(encodingStyle); tryToFindEncodingStyleAttributeName(); }
@Override public void writeAttribute(final String prefix, final String ns, final String ln, final String value) throws XMLStreamException { try { if (ns == null) { if (prefix == null && xmlns.equals(ln)) { currentElement.addNamespaceDeclaration("", value); } else { currentElement.setAttributeNS("", ln, value); } } else { QName name = (prefix == null) ? new QName(ns, ln) : new QName(ns, ln, prefix); currentElement.addAttribute(name, value); } } catch (SOAPException e) { throw new XMLStreamException(e); } }
/** * Member level service call. No NS prefix on request. No NS prefix on * response, set with an empty string. * @throws XRd4JException * @throws SOAPException */ public void test2() throws XRd4JException, SOAPException { String requestStr = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"MEMBER\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.5</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><getRandom xmlns=\"http://consumer.x-road.ee\"><request><data>Request data</data></request></getRandom></SOAP-ENV:Body></SOAP-ENV:Envelope>"; String correctResponse = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"MEMBER\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.5</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><getRandomResponse xmlns=\"http://foobar.x-road.ee/producer\"><request><data>Request data</data></request><response><data>Response data</data></response></getRandomResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>"; ConsumerMember consumer = new ConsumerMember("FI", "GOV", "MEMBER1"); ProducerMember producer = new ProducerMember("FI", "COM", "MEMBER2", "subsystem", "getRandom", "v1"); ServiceRequest<String> request = new ServiceRequest<String>(consumer, producer, "1234567890"); request.setUserId("EE1234567890"); request.setProtocolVersion("4.5"); request.setRequestData("Request data"); request.setSoapMessage(SOAPHelper.toSOAP(requestStr)); request.getProducer().setNamespacePrefix(""); request.getProducer().setNamespaceUrl("http://foobar.x-road.ee/producer"); ServiceResponse<String, String> response = new ServiceResponse<String, String>(request.getConsumer(), request.getProducer(), request.getId()); response.setResponseData("Response data"); ServiceResponseSerializer serializer = new ServiceResponseSerializerImpl(); SOAPMessage msg = serializer.serialize(response, request); assertEquals(correctResponse, SOAPHelper.toString(msg)); }
protected Throwable getProtocolException() { try { SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode); fault.setFaultActor(faultactor); if(detail != null){ Detail d = fault.addDetail(); for(Element det : detail.getDetails()){ Node n = fault.getOwnerDocument().importNode(det, true); d.appendChild(n); } } return new ServerSOAPFaultException(fault); } catch (SOAPException e) { throw new WebServiceException(e); } }
/** * Subsystem level service call. Use producer namespace prefix in response. * @throws XRd4JException * @throws SOAPException */ public void test6() throws XRd4JException, SOAPException { String requestStr = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.0</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getRandom xmlns:ns1=\"http://consumer.x-road.ee\"><request><data>Request data</data></request></ns1:getRandom></SOAP-ENV:Body></SOAP-ENV:Envelope>"; String correctResponse = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.0</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><xxprod:getRandomResponse xmlns:xxprod=\"http://foobar.x-road.ee/producer\"><xxprod:request><xxprod:data>Request data</xxprod:data></xxprod:request><xxprod:response><xxprod:data>Response data</xxprod:data></xxprod:response></xxprod:getRandomResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>"; ConsumerMember consumer = new ConsumerMember("FI", "GOV", "MEMBER1", "subsystem"); ProducerMember producer = new ProducerMember("FI", "COM", "MEMBER2", "subsystem", "getRandom", "v1"); ServiceRequest<String> request = new ServiceRequest<String>(consumer, producer, "1234567890"); request.setUserId("EE1234567890"); request.setRequestData("Request data"); request.setSoapMessage(SOAPHelper.toSOAP(requestStr)); request.getProducer().setNamespacePrefix("xxprod"); request.getProducer().setNamespaceUrl("http://foobar.x-road.ee/producer"); ServiceResponse<String, String> response = new ServiceResponse<String, String>(request.getConsumer(), request.getProducer(), request.getId()); response.setResponseData("Response data"); ServiceResponseSerializer serializer = new ServiceResponseSerializerImpl(); SOAPMessage msg = serializer.serialize(response, request); assertEquals(correctResponse, SOAPHelper.toString(msg)); }
@Override public boolean add(Header header) { try { header.writeTo(sm); } catch (SOAPException e) { //TODO log exception return false; } //the newly added header is not understood by default notUnderstood(new QName(header.getNamespaceURI(), header.getLocalPart())); //track non saaj headers so that they can be retrieved later if (isNonSAAJHeader(header)) { //TODO assumes only one header with that name? addNonSAAJHeader(find(header.getNamespaceURI(), header.getLocalPart()), header); } return true; }
/** * Generates SOAP body, including the request and response elements. * * @param response ServiceResponse to be serialized * @param soapRequest request's SOAP message object that's used for copying * the request element * @throws SOAPException if there's a SOAP error */ private void serializeBody(final ServiceResponse response, final SOAPMessage soapRequest) throws SOAPException, XRd4JException { LOGGER.debug("Generate SOAP body."); if (response.isAddNamespaceToServiceResponse() || response.isAddNamespaceToRequest() || response.isAddNamespaceToResponse()) { if (response.getProducer().getNamespaceUrl() == null || response.getProducer().getNamespaceUrl().isEmpty()) { throw new XRd4JException("Producer namespace URI can't be null or empty."); } LOGGER.debug("Producer namespace \"{}\".", response.getProducer().getNamespaceUrl()); } // Body - Start SOAPEnvelope envelope = response.getSoapMessage().getSOAPPart().getEnvelope(); SOAPBody body = envelope.getBody(); Name bodyName; if (response.isAddNamespaceToServiceResponse()) { LOGGER.debug("Create service response with namespace."); bodyName = envelope.createName(response.getProducer().getServiceCode() + "Response", response.getProducer().getNamespacePrefix(), response.getProducer().getNamespaceUrl()); } else { LOGGER.debug("Create service response without namespace."); bodyName = envelope.createName(response.getProducer().getServiceCode() + "Response"); } SOAPBodyElement gltp = body.addBodyElement(bodyName); // Process SOAP body SOAPElement soapResponse = processBody(gltp, response, soapRequest, envelope); // Process the actual payload processBodyContent(soapResponse, response, envelope); LOGGER.debug("SOAP body was generated succesfully."); }
@Override public SOAPFault createFault() throws SOAPException { Fault1_2Impl fault = new Fault1_2Impl(createDocument()); fault.setFaultCode(fault.getDefaultFaultCode()); fault.setFaultString("Fault string, and possibly fault code, not set"); return fault; }
@Test(expected = SOAPException.class) public void exec_SOAPException() throws Exception { // given doThrow(new SOAPException()).when(message).getSOAPBody(); // when adapter.exec(context, new ExceptionDetail( ModificationType.ADDEXCEPTION, ModificationPart.EXCEPTION, new VariableInfo("", ""), "newExceptionName")); }
@Override public SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException { if (faultCode == null) { throw new IllegalArgumentException("faultCode argument for createFault was passed NULL"); } if (reasonText == null) { throw new IllegalArgumentException("reasonText argument for createFault was passed NULL"); } Fault1_2Impl fault = new Fault1_2Impl(createDocument()); fault.setFaultCode(faultCode); fault.setFaultString(reasonText); return fault; }
@Override public void setFaultString( String faultString, Locale locale) throws SOAPException { addFaultReasonText(faultString, locale); }
/** * Client list with 4 members (2 * MEMBER, 2 * SUBSYSTEM) * * @throws XRd4JException * @throws SOAPException */ public void test3() throws XRd4JException, SOAPException { String soapString = "<?xml version=\"1.0\"?><ns2:clientList xmlns:ns1=\"http://x-road.eu/xsd/identifiers\" xmlns:ns2=\"http://x-road.eu/xsd/xroad.xsd\"><ns2:member><ns2:id ns1:objectType=\"MEMBER\"><ns1:xRoadInstance>FI-DEV63</ns1:xRoadInstance><ns1:memberClass>GOV</ns1:memberClass><ns1:memberCode>7654321-0</ns1:memberCode></ns2:id><ns2:name>Org 1</ns2:name></ns2:member><ns2:member><ns2:id ns1:objectType=\"MEMBER\"><ns1:xRoadInstance>FI-DEV63</ns1:xRoadInstance><ns1:memberClass>GOV</ns1:memberClass><ns1:memberCode>1234567-8</ns1:memberCode></ns2:id><ns2:name>Org 2</ns2:name></ns2:member><ns2:member><ns2:id ns1:objectType=\"SUBSYSTEM\"><ns1:xRoadInstance>FI-DEV63</ns1:xRoadInstance><ns1:memberClass>GOV</ns1:memberClass><ns1:memberCode>1234567-8</ns1:memberCode><ns1:subsystemCode>TestClient</ns1:subsystemCode></ns2:id><ns2:name>Org 2</ns2:name></ns2:member><ns2:member><ns2:id ns1:objectType=\"SUBSYSTEM\"><ns1:xRoadInstance>FI-DEV63</ns1:xRoadInstance><ns1:memberClass>GOV</ns1:memberClass><ns1:memberCode>1234567-8</ns1:memberCode><ns1:subsystemCode>TestService</ns1:subsystemCode></ns2:id><ns2:name>Org 2</ns2:name></ns2:member></ns2:clientList>"; List<ConsumerMember> list = new ListClientsResponseDeserializer().deserializeConsumerList(soapString); assertEquals("FI-DEV63", list.get(0).getXRoadInstance()); assertEquals("GOV", list.get(0).getMemberClass()); assertEquals("7654321-0", list.get(0).getMemberCode()); assertEquals(null, list.get(0).getSubsystemCode()); assertEquals(ObjectType.MEMBER, list.get(0).getObjectType()); assertEquals("FI-DEV63", list.get(1).getXRoadInstance()); assertEquals("GOV", list.get(1).getMemberClass()); assertEquals("1234567-8", list.get(1).getMemberCode()); assertEquals(null, list.get(1).getSubsystemCode()); assertEquals(ObjectType.MEMBER, list.get(1).getObjectType()); assertEquals("FI-DEV63", list.get(2).getXRoadInstance()); assertEquals("GOV", list.get(2).getMemberClass()); assertEquals("1234567-8", list.get(2).getMemberCode()); assertEquals("TestClient", list.get(2).getSubsystemCode()); assertEquals(ObjectType.SUBSYSTEM, list.get(2).getObjectType()); assertEquals("FI-DEV63", list.get(3).getXRoadInstance()); assertEquals("GOV", list.get(3).getMemberClass()); assertEquals("1234567-8", list.get(3).getMemberCode()); assertEquals("TestService", list.get(3).getSubsystemCode()); assertEquals(ObjectType.SUBSYSTEM, list.get(3).getObjectType()); }
@Override public SOAPBodyElement addBodyElement(QName qname) throws SOAPException { SOAPBodyElement newBodyElement = (SOAPBodyElement) ElementFactory.createNamedElement( ((SOAPDocument) getOwnerDocument()).getDocument(), qname.getLocalPart(), qname.getPrefix(), qname.getNamespaceURI()); if (newBodyElement == null) { newBodyElement = createBodyElement(qname); } addNode(newBodyElement); return newBodyElement; }
/** * Test that reading target url keeps giving the same url * @throws SOAPException */ public void test2() throws SOAPException { List<String> urls = new ArrayList<>(); urls.add("http://server1.myhost.com"); LoadBalancedSOAPClientImpl client = new LoadBalancedSOAPClientImpl(urls); assertEquals("http://server1.myhost.com", client.getTargetUrl()); assertEquals("http://server1.myhost.com", client.getTargetUrl()); assertEquals("http://server1.myhost.com", client.getTargetUrl()); }
@Override public SOAPHeaderElement addUpgradeHeaderElement(Iterator supportedSoapUris) throws SOAPException { if (supportedSoapUris == null) { log.severe("SAAJ0411.ver1_2.no.null.supportedURIs"); throw new SOAPException("Argument cannot be null; iterator of supportedURIs cannot be null"); } if (!supportedSoapUris.hasNext()) { log.severe("SAAJ0412.ver1_2.no.empty.list.of.supportedURIs"); throw new SOAPException("List of supported URIs cannot be empty"); } Name upgradeName = getUpgradeName(); SOAPHeaderElement upgradeHeaderElement = (SOAPHeaderElement) addChildElement(upgradeName); Name supportedEnvelopeName = getSupportedEnvelopeName(); int i = 0; while (supportedSoapUris.hasNext()) { SOAPElement subElement = upgradeHeaderElement.addChildElement(supportedEnvelopeName); String ns = "ns" + Integer.toString(i); subElement.addAttribute( NameImpl.createFromUnqualifiedName("qname"), ns + ":Envelope"); subElement.addNamespaceDeclaration( ns, (String) supportedSoapUris.next()); i ++; } return upgradeHeaderElement; }
@Override public SOAPElement addTextNode(String text) throws SOAPException { if (text.startsWith(CDATAImpl.cdataUC) || text.startsWith(CDATAImpl.cdataLC)) return addCDATA( text.substring(CDATAImpl.cdataUC.length(), text.length() - 3)); return addText(text); }
/** * Response to subsystem -> service level service call. Non technical error. * Camel case element names. Fault code only. * * @throws XRd4JException * @throws SOAPException */ public void testNonTechError3() throws XRd4JException, SOAPException { String soapString = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:id>ID-1234567890</xrd:id><xrd:protocolVersion>4.0</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getRandomResponse xmlns:ns1=\"http://producer.x-road.ee\"><request><data>1234567890</data></request><response><faultCode>fault code</faultCode></response></ns1:getRandomResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>"; SOAPMessage msg = SOAPHelper.toSOAP(soapString); ServiceResponseDeserializer deserializer = new TestResponseDeserializer(); ServiceResponse<String, String> response = deserializer.deserialize(msg); assertEquals("FI", response.getConsumer().getXRoadInstance()); assertEquals("GOV", response.getConsumer().getMemberClass()); assertEquals("MEMBER1", response.getConsumer().getMemberCode()); assertEquals("subsystem", response.getConsumer().getSubsystemCode()); assertEquals(ObjectType.SUBSYSTEM, response.getConsumer().getObjectType()); assertEquals("FI", response.getProducer().getXRoadInstance()); assertEquals("COM", response.getProducer().getMemberClass()); assertEquals("MEMBER2", response.getProducer().getMemberCode()); assertEquals("subsystem", response.getProducer().getSubsystemCode()); assertEquals("getRandom", response.getProducer().getServiceCode()); assertEquals("v1", response.getProducer().getServiceVersion()); assertEquals("ID-1234567890", response.getId()); assertEquals(null, response.getUserId()); assertEquals("4.0", response.getProtocolVersion()); assertEquals(ObjectType.SERVICE, response.getProducer().getObjectType()); assertEquals("1234567890", response.getRequestData()); assertEquals(null, response.getResponseData()); assertEquals(null, response.getRequestHashAlgorithm()); assertEquals(null, response.getRequestHash()); assertEquals(true, response.hasError()); assertEquals("fault code", response.getErrorMessage().getFaultCode()); assertEquals(null, response.getErrorMessage().getFaultString()); assertEquals(ErrorMessageType.NON_TECHNICAL_SOAP_ERROR_MESSAGE, response.getErrorMessage().getErrorMessageType()); assertEquals(true, response.getSoapMessage() != null); assertEquals(true, response.getSecurityServer() == null); }
private SOAPFaultException createDuplicateHeaderException() { try { SOAPFault fault = soapVersion.getSOAPFactory().createFault(); fault.setFaultCode(soapVersion.faultCodeClient); fault.setFaultString(ServerMessages.DUPLICATE_PORT_KNOWN_HEADER(headerName)); return new SOAPFaultException(fault); } catch(SOAPException e) { throw new WebServiceException(e); } }
private void handleMTOMUploads(String sessionID, Iterator<?> iterator) throws FileNotFoundException, IOException, SOAPException { while (iterator.hasNext()) { Object element = iterator.next(); if (element instanceof SOAPElement) { handleMTOMUploads(sessionID, (SOAPElement)element); handleMTOMUploads(sessionID, ((SOAPElement)element).getChildElements()); } } }
@Override public void setParentElement(SOAPElement element) throws SOAPException { if (element == null) { log.severe("SAAJ0106.impl.no.null.to.parent.elem"); throw new SOAPException("Cannot pass NULL to setParentElement"); } element.addChildElement(this); findEncodingStyleAttributeName(); }
public SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException { if (faultCode == null) { throw new IllegalArgumentException("faultCode argument for createFault was passed NULL"); } if (reasonText == null) { throw new IllegalArgumentException("reasonText argument for createFault was passed NULL"); } Fault1_2Impl fault = new Fault1_2Impl(createDocument(), null); fault.setFaultCode(faultCode); fault.setFaultString(reasonText); return fault; }
/** * Recursively populate the Subcodes */ private void fillFaultSubCodes(SOAPFault fault, SubcodeType subcode) throws SOAPException { if(subcode != null){ fault.appendFaultSubcode(subcode.getValue()); fillFaultSubCodes(fault, subcode.getSubcode()); } }
protected void addSoapHeader(SOAPMessage soapMessage) throws SOAPException, NoSuchAlgorithmException { onvifDevice.createNonce(); String encrypedPassword = onvifDevice.getEncryptedPassword(); if (encrypedPassword != null && onvifDevice.getUsername() != null) { SOAPPart sp = soapMessage.getSOAPPart(); SOAPEnvelope se = sp.getEnvelope(); SOAPHeader header = soapMessage.getSOAPHeader(); se.addNamespaceDeclaration("wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); se.addNamespaceDeclaration("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); SOAPElement securityElem = header.addChildElement("Security", "wsse"); // securityElem.setAttribute("SOAP-ENV:mustUnderstand", "1"); SOAPElement usernameTokenElem = securityElem.addChildElement("UsernameToken", "wsse"); SOAPElement usernameElem = usernameTokenElem.addChildElement("Username", "wsse"); usernameElem.setTextContent(onvifDevice.getUsername()); SOAPElement passwordElem = usernameTokenElem.addChildElement("Password", "wsse"); passwordElem.setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"); passwordElem.setTextContent(encrypedPassword); SOAPElement nonceElem = usernameTokenElem.addChildElement("Nonce", "wsse"); nonceElem.setAttribute("EncodingType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"); nonceElem.setTextContent(onvifDevice.getEncryptedNonce()); SOAPElement createdElem = usernameTokenElem.addChildElement("Created", "wsu"); createdElem.setTextContent(onvifDevice.getLastUTCTime()); } }
public SOAPElement setElementQName(QName newName) throws SOAPException { log.log(Level.SEVERE, "SAAJ0146.impl.invalid.name.change.requested", new Object[] {elementQName.getLocalPart(), newName.getLocalPart()}); throw new SOAPException("Cannot change name for " + elementQName.getLocalPart() + " to " + newName.getLocalPart()); }
@Then("verify that response is similar to file '$filePath'") public void verifyThatResponseIsSimilarToFile(String filePath) throws SOAPException, IOException, SAXException { FileReader expectedResponseXML = new FileReader(getFileFromResourcesByFilePath(filePath)); SOAPMessage rawSoapResponse = (SOAPMessage) Thucydides.getCurrentSession().get(RESPONSE); String cleanResponse = getXmlPayload(rawSoapResponse); StringReader actualResponseXML = new StringReader(cleanResponse); Diff diff = new Diff(expectedResponseXML, actualResponseXML); diff.overrideDifferenceListener(new IgnoreTextAndAttributeValuesDifferenceListener()); StringBuffer stringBuffer = diff.appendMessage(new StringBuffer()); assertTrue(stringBuffer.toString(), diff.similar()); }
/** * Request from subsystem to service, wrong MemberClass. * * @throws XRd4JException * @throws SOAPException */ public void testException3() throws SOAPException, XRd4JException { ServiceRequest<String> request = null; try { String soapString = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>TEST</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getRandom xmlns:ns1=\"http://consumer.x-road.ee\"><request><data>1234567890</data></request></ns1:getRandom></SOAP-ENV:Body></SOAP-ENV:Envelope>"; SOAPMessage msg = SOAPHelper.toSOAP(soapString); ServiceRequestDeserializer deserializer = new ServiceRequestDeserializerImpl(); request = deserializer.deserialize(msg); fail("Should not reach this"); } catch (XRd4JException ex) { // OK } }
public void writeTo(SOAPMessage saaj) throws SOAPException { SOAPHeader header = saaj.getSOAPHeader(); if(header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); SOAPHeaderElement she = header.addHeaderElement(new QName(getNamespaceURI(), getLocalPart())); she.addChildElement(actionLocalName); she.addTextNode(action); if (soapAction != null) { she.addChildElement(soapActionLocalName); she.addTextNode(soapAction); } }
public void writeTo(SOAPMessage saaj) throws SOAPException { try { SOAPHeader header = saaj.getSOAPHeader(); if (header == null) header = saaj.getSOAPPart().getEnvelope().addHeader(); bridge.marshal(jaxbObject,header); } catch (JAXBException e) { throw new SOAPException(e); } }