<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: tESBConsumer creates 2 Username Tokens for Security Header in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/tESBConsumer-creates-2-Username-Tokens-for-Security-Header/m-p/2327879#M97222</link>
    <description>&lt;P&gt;Thanks I edited your solution to my needs and now it works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Mar 2018 12:19:41 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-03-22T12:19:41Z</dc:date>
    <item>
      <title>tESBConsumer creates 2 Username Tokens for Security Header</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tESBConsumer-creates-2-Username-Tokens-for-Security-Header/m-p/2327877#M97220</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using Talend DI 6.4.1 and I try to call a web service with the tESBConsumer component, which requires WS-Security. I activated "Use Authentication with Username Token" in the component.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Talend generates the following request:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&amp;gt;
	&amp;lt;soap:Header&amp;gt;
		&amp;lt;wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
		soap:mustUnderstand="1"&amp;gt;
			&amp;lt;wsu:Timestamp wsu:Id="TS-ee13dd41-295c-4312-bf14-591aef92f522"&amp;gt;
				&amp;lt;wsu:Created&amp;gt;2018-03-21T11:19:15.236Z&amp;lt;/wsu:Created&amp;gt;
				&amp;lt;wsu:Expires&amp;gt;2018-03-21T11:24:15.236Z&amp;lt;/wsu:Expires&amp;gt;
			&amp;lt;/wsu:Timestamp&amp;gt;
			&amp;lt;wsse:UsernameToken wsu:Id="UsernameToken-8787d266-3d73-4bf0-b851-173e3baf7dc2"&amp;gt;
				&amp;lt;wsse:Username&amp;gt;xxxx&amp;lt;/wsse:Username&amp;gt;
				&amp;lt;wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"&amp;gt;xxxx&amp;lt;/wsse:Password&amp;gt;
				&amp;lt;wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"&amp;gt;DhH7/Td855EjxnIOMt3MWA==&amp;lt;/wsse:Nonce&amp;gt;
				&amp;lt;wsu:Created&amp;gt;2018-03-21T11:19:15.242Z&amp;lt;/wsu:Created&amp;gt;
			&amp;lt;/wsse:UsernameToken&amp;gt;
			&lt;STRONG&gt;&amp;lt;wsse:UsernameToken wsu:Id="UsernameToken-11329e95-7124-42c9-b0f6-33aee4b32ac8"&amp;gt;
				&amp;lt;wsse:Username&amp;gt;xxxx&amp;lt;/wsse:Username&amp;gt;
				&amp;lt;wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"&amp;gt;xxxx&amp;lt;/wsse:Password&amp;gt;
			&amp;lt;/wsse:UsernameToken&amp;gt;&lt;/STRONG&gt;
		&amp;lt;/wsse:Security&amp;gt;
	&amp;lt;/soap:Header&amp;gt;
	&amp;lt;soap:Body&amp;gt;
...
	&amp;lt;/soap:Body&amp;gt;
&amp;lt;/soap:Envelope&amp;gt;&lt;/PRE&gt;
&lt;P&gt;SoapUI generates the same request except the second Username token with "PasswordText". I also checked the WSDL file and in the policy it only asks for Username token with "PasswordDigest".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The service always response with "{&lt;A href="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}InvalidSecurity|Error" target="_blank" rel="nofollow noopener noreferrer"&gt;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}InvalidSecurity|Error&lt;/A&gt; on verifying message against security policy Error code:1025||||".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a possibility to tell Talend to only generate one Token?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 08:31:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tESBConsumer-creates-2-Username-Tokens-for-Security-Header/m-p/2327877#M97220</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T08:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: tESBConsumer creates 2 Username Tokens for Security Header</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tESBConsumer-creates-2-Username-Tokens-for-Security-Header/m-p/2327878#M97221</link>
      <description>&lt;P&gt;I believe I have experienced this issue before (with 6.2.1). Are you working with a Microsoft exposed SOAP service? It appears that Microsoft have bent the rules with SOAP standards (as they did with web browsers) and Talend does not work to those standards.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;To get around this, I ended up using a tSOAP and building my own SOAP body as required in code. I saved the SOAP body with the XML document embedded into&amp;nbsp;the globalMap and referenced the globalMap in the tSOAP "SOAP Message" field.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;package routines;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.StringReader;

import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;

import org.dom4j.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;


public class SoapHeaderHandler {

	public static String createSoapMessage(org.dom4j.Document document, String username, String password){
		String returnVal = "";
		
		MessageFactory messageFactory;
		
		try {
			messageFactory = MessageFactory.newInstance();
			
		SOAPMessage soapMessage = messageFactory.createMessage();

		// Retrieve different parts
		SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();

		// Two ways to extract body
		SOAPBody soapBody = soapEnvelope.getBody();
		soapBody = soapMessage.getSOAPBody();
		soapEnvelope.getHeader().detachNode();
	    SOAPHeader soapHeader = soapEnvelope.addHeader();

        SOAPElement security =
                soapHeader.addChildElement("Security", "wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");



        SOAPElement usernameToken =
                security.addChildElement("UsernameToken", "wsse");
        usernameToken.addAttribute(new QName("xmlns:wsu"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");

        SOAPElement soapUsername =
                usernameToken.addChildElement("Username", "wsse");
        soapUsername.addTextNode(username);

        SOAPElement soapPassword =
                usernameToken.addChildElement("Password", "wsse");
        soapPassword.setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
       soapPassword.addTextNode(password);

   
       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
       factory.setNamespaceAware(true);
       DocumentBuilder builder = factory.newDocumentBuilder();
       org.w3c.dom.Document w3cDoc = builder.parse(new InputSource(new StringReader(document.asXML())));
       
       soapBody.addDocument(w3cDoc);
       
        //Print out the outbound SOAP message to System.out
        
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       soapMessage.writeTo(baos);
       
       returnVal = baos.toString("UTF-8");
       //System.out.println(returnVal);
		} catch (SOAPException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SAXException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return returnVal;
	}

}&lt;/PRE&gt; 
&lt;P&gt;I call this by first preparing my payload document in a tXMLMap and then passing it to a tMap where I call the following code.....&lt;/P&gt; 
&lt;PRE&gt;routines.SoapHeaderHandler.createSoapMessage(((org.dom4j.Document)row1.payload.getDocument()), context.Username, context.Password) &lt;/PRE&gt; 
&lt;P&gt;The String that is returned is then added to my tSOAP.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;It is convoluted, but it works.&lt;/P&gt; 
&lt;P&gt;If you have access to Talend support I would raise this so that they can spend a bit more time with you if this is too convoluted.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Hope it helps&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 10:18:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tESBConsumer-creates-2-Username-Tokens-for-Security-Header/m-p/2327878#M97221</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-22T10:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: tESBConsumer creates 2 Username Tokens for Security Header</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tESBConsumer-creates-2-Username-Tokens-for-Security-Header/m-p/2327879#M97222</link>
      <description>&lt;P&gt;Thanks I edited your solution to my needs and now it works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 12:19:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tESBConsumer-creates-2-Username-Tokens-for-Security-Header/m-p/2327879#M97222</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-22T12:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: tESBConsumer creates 2 Username Tokens for Security Header</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tESBConsumer-creates-2-Username-Tokens-for-Security-Header/m-p/2327880#M97223</link>
      <description>&lt;P&gt;No problem. I had a nightmare with this problem until I figured out how to resolve it. Glad I could help prevent you from losing so much time trying to resolve this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 12:39:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tESBConsumer-creates-2-Username-Tokens-for-Security-Header/m-p/2327880#M97223</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-22T12:39:38Z</dc:date>
    </item>
  </channel>
</rss>

