WebServiceSender extends HttpSender { @Override public void configure() throws ConfigurationException { super.configure(); if (isSoap()) { } soapWrapper = SoapWrapper.getInstance(); if (paramList!=null && StringUtils.isNotEmpty(getSoapActionParam())) { soapActionParameter=paramList.findParameter(getSoapActionParam()); if(soapActionParameter != null) addParameterToSkip(soapActionParameter.getName()); serviceNamespaceURIParameter=paramList.findParameter(getServiceNamespaceParam()); if(serviceNamespaceURIParameter != null) addParameterToSkip(serviceNamespaceURIParameter.getName()); } if (StringUtils.isNotEmpty(getWssAuthAlias()) || StringUtils.isNotEmpty(getWssUserName())) { wsscf = new CredentialFactory(getWssAuthAlias(), getWssUserName(), getWssPassword()); log.debug(getLogPrefix()+"created CredentialFactory for username=["+wsscf.getUsername()+"]"); } } WebServiceSender(); @Override String getLogPrefix(); @Override void configure(); @IbisDoc({"when <code>true</code>, messages sent are put in a soap envelope and the soap envelope is removed from received messages (soap envelope will not be visible to the pipeline)", "<code>true</code>"}) void setSoap(boolean b); boolean isSoap(); @Deprecated @ConfigurationWarning("the attribute 'soapActionURI' has been renamed to 'soapAction'") void setSoapActionURI(String soapAction); @Deprecated @ConfigurationWarning("the attribute 'soapActionURIParam' has been renamed to 'soapActionParam'") void setSoapActionURIParam(String soapActionParam); String getSoapAction(); @IbisDoc({"the soapactionuri to be set in the requestheader", ""}) void setSoapAction(String soapAction); String getSoapActionParam(); @IbisDoc({"parameter to obtain the soapactionuri", ""}) void setSoapActionParam(String soapActionParam); @Deprecated @ConfigurationWarning("the attribute 'encodingStyleURI' has been renamed to 'encodingStyle'") void setEncodingStyleURI(String encodingStyle); @IbisDoc({"the encodingstyle to be set in the messageheader", ""}) void setEncodingStyle(String encodingStyle); String getEncodingStyle(); @IbisDoc({"controls whether soap faults generated by the application generate an exception, or are treated as 'normal' messages", "true"}) void setThrowApplicationFaults(boolean b); boolean isThrowApplicationFaults(); @Deprecated @ConfigurationWarning("the attribute 'serviceNamespaceURI' has been renamed to 'serviceNamespace'") void setServiceNamespaceURI(String serviceNamespace); @IbisDoc({"the namespace of the message sent. identifies the service to be called. may be overriden by an actual namespace setting in the message to be sent", ""}) void setServiceNamespace(String serviceNamespace); String getServiceNamespace(); @Deprecated @ConfigurationWarning("the attribute 'serviceNamespaceURIParam' has been renamed to 'serviceNamespaceParam'") void setServiceNamespaceURIParam(String serviceNamespaceParam); @IbisDoc({"parameter to obtain the servicenamespace", ""}) void setServiceNamespaceParam(String serviceNamespaceParam); String getServiceNamespaceParam(); @IbisDoc({"namespace defintions to be added in the soap envelope tag. must be in the form of a comma or space separated list of <code>prefix=namespaceuri</code>-definitions", ""}) void setNamespaceDefs(String namespaceDefs); String getNamespaceDefs(); @IbisDoc({"", " "}) void setWssUserName(String string); String getWssUserName(); @IbisDoc({"", " "}) void setWssPassword(String string); String getWssPassword(); @IbisDoc({"alias used to obtain credentials for authentication to web services security", ""}) void setWssAuthAlias(String string); String getWssAuthAlias(); @IbisDoc({"when true, the password is sent digested. otherwise it is sent in clear text", "true"}) void setWssPasswordDigest(boolean b); boolean isWssPasswordDigest();  }
@Test public void simpleMockedWss() throws Throwable { WebServiceSender sender = getSender(); Message input = new Message("<hallo/>"); try { IPipeLineSession pls = new PipeLineSessionBase(session); sender.configure(); sender.open(); String result = sender.sendMessage(input, pls).asString(); assertEquals(getFile("simpleMockedWss.txt"), result.trim()); } catch (SenderException e) { throw e.getCause(); } }
@Test public void simpleMockedWssMultipart() throws Throwable { WebServiceSender sender = getSender(); Message input = new Message("<xml>input</xml>"); try { IPipeLineSession pls = new PipeLineSessionBase(session); sender.setMethodType("POST"); sender.setParamsInUrl(false); sender.setInputMessageParam("request"); String xmlMultipart = "<parts><part type=\"file\" name=\"document.pdf\" " + "sessionKey=\"part_file\" size=\"72833\" " + "mimeType=\"application/pdf\"/></parts>"; pls.put("multipartXml", xmlMultipart); pls.put("part_file", new ByteArrayInputStream("<dummy xml file/>".getBytes())); sender.setMultipartXmlSessionKey("multipartXml"); sender.configure(); sender.open(); String result = sender.sendMessage(input, pls).asString();; assertEquals(getFile("simpleMockedWssMultipart.txt"), result.trim()); } catch (SenderException e) { throw e.getCause(); } }
@Test public void simpleMockedWssMultipart2() throws Throwable { WebServiceSender sender = getSender(); Message input = new Message("<xml>input</xml>"); try { IPipeLineSession pls = new PipeLineSessionBase(session); sender.setMethodType("POST"); sender.setParamsInUrl(false); sender.setInputMessageParam("request"); String xmlMultipart = "<parts>" + "<part type=\"file\" name=\"document1.pdf\" sessionKey=\"part_file1\" mimeType=\"application/pdf\"/>" + "<part type=\"file\" name=\"document2.pdf\" sessionKey=\"part_file2\" mimeType=\"application/pdf\"/>" + "</parts>"; pls.put("multipartXml", xmlMultipart); pls.put("part_file1", new ByteArrayInputStream("<dummy pdf file/>".getBytes())); pls.put("part_file2", new ByteArrayInputStream("<dummy pdf file/>".getBytes())); sender.setMultipartXmlSessionKey("multipartXml"); sender.configure(); sender.open(); String result = sender.sendMessage(input, pls).asString();; assertEquals(getFile("simpleMockedWssMultipart2.txt"), result.trim()); } catch (SenderException e) { throw e.getCause(); } }
@Test public void simpleMockedWssMtom() throws Throwable { WebServiceSender sender = getSender(); Message input = new Message("<xml>input</xml>"); try { IPipeLineSession pls = new PipeLineSessionBase(session); sender.setMethodType("POST"); sender.setParamsInUrl(false); sender.setInputMessageParam("request"); String xmlMultipart = "<parts><part type=\"file\" name=\"document.pdf\" " + "sessionKey=\"part_file\" size=\"72833\" " + "mimeType=\"application/pdf\"/></parts>"; pls.put("multipartXml", xmlMultipart); pls.put("part_file", new ByteArrayInputStream("<dummy xml file/>".getBytes())); sender.setMtomEnabled(true); sender.setMultipartXmlSessionKey("multipartXml"); sender.configure(); sender.open(); String result = sender.sendMessage(input, pls).asString(); assertEquals(getFile("simpleMockedWssMtom.txt"), result.trim()); } catch (SenderException e) { throw e.getCause(); } }
@Test public void simpleMockedWssMultipartMtomWithParameter() throws Throwable { WebServiceSender sender = getSender(); Message input = new Message("<xml>hello world</xml>"); try { IPipeLineSession pls = new PipeLineSessionBase(session); sender.setParamsInUrl(false); sender.setInputMessageParam("file"); sender.setMultipart(true); sender.setAllowSelfSignedCertificates(true); sender.setVerifyHostname(false); sender.setMtomEnabled(true); Parameter param = new Parameter(); param.setName("file"); param.setValue("<xml>I just sent some text! :)</xml>"); sender.addParameter(param); sender.configure(); sender.open(); String result = sender.sendMessage(input, pls).asString(); assertEquals(getFile("simpleMockedWssMultipartMtom.txt"), result.trim()); } catch (SenderException e) { throw e.getCause(); } }