<html><body><div style="color:#000; background-color:#fff; font-family:tahoma, new york, times, serif;font-size:10pt">Thanks Brent. It would be great help if you could look into the code to see if I need to change something. <br><br>Also, before the message is sent I would like to output the message (envelope with header,body and the saml response) to the console. How can I achieve this? I can output just the saml response using:<br><span class="tab"> </span>ResponseMarshaller marshaller = new ResponseMarshaller();<br> Element plaintextElement = marshaller.marshall(samlResponse);<br> String responseString = XMLHelper.nodeToString(plaintextElement);<br> System.out.println("SAML response: " + responseString);<br><br>Can I do something similar to output the entire
message?<br><div><span><br></span></div><div><br></div> <div style="font-family: tahoma, new york, times, serif; font-size: 10pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> Brent Putman <putmanb@georgetown.edu><br> <b><span style="font-weight: bold;">To:</span></b> dev@shibboleth.net <br> <b><span style="font-weight: bold;">Sent:</span></b> Wednesday, December 12, 2012 2:22 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: Missing SOAP header in ECP response<br> </font> </div> <br>
<div id="yiv848773346">
<div>
<br>
<div class="yiv848773346moz-cite-prefix">On 12/12/12 12:43 PM, Mitu Singh wrote:<br>
</div>
<blockquote type="cite">
<div style="color:#000;background-color:#fff;font-family:tahoma, new york, times, serif;font-size:10pt;">
<div style="font-family:tahoma, new york, times, serif;font-size:10pt;">
<div style="font-family:times new roman, new york, times, serif;font-size:12pt;">
<div id="yiv848773346">
<div>
<div style="color:#000;background-color:#fff;font-family:tahoma, new york, times, serif;font-size:10pt;">
<div style="font-family:tahoma, new york, times, serif;font-size:10pt;">
<div style="font-family:times new roman, new york, times, serif;font-size:12pt;">
<div id="yiv848773346">
<div>
<div style="color:#000;background-color:#fff;font-family:tahoma, new york, times, serif;font-size:10pt;"><br>
<div class="yiv848773346MsoNormal">I have
tried a number of ways to include the
header, but it
is not being set. This is how I have done
it:<span class="yiv848773346tab"> </span><span class="yiv848773346tab"> </span><span class="yiv848773346tab"> </span><span class="yiv848773346tab"> </span>
<div class="yiv848773346MsoNormal"><span class="yiv848773346tab"> </span><span class="yiv848773346tab"> </span><span class="yiv848773346tab"> </span><span class="yiv848773346tab"> </span><span class="yiv848773346tab"> </span><span style="color:#4F81BD;">HttpServletResponseAdapter
outTransport
= new
HttpServletResponseAdapter(httpResponse,
false);</span> <br>
</div>
</div>
<div class="yiv848773346MsoNormal" style="margin-left:.5in;text-indent:.5in;"><u><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">BasicSAMLMessageContext</span></u><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">
messageContext = <b>new</b>
<u>BasicSAMLMessageContext</u>();</span><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">
</span>
</div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">
messageContext.setOutboundMessageTransport(outTransport);</span><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">
</span>
</div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">
SOAPObjectBuilder<Envelope>
envelopeBuilder =
(SOAPObjectBuilder<Envelope>)
builderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);</span></div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">
Envelope envelope =
envelopeBuilder.buildObject(); </span></div>
<span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;"> </span>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;"> messageContext.setOutboundMessage(envelope);
</span></div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;"> messageContext.setOutboundSAMLMessage(authResponse);</span><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">
</span>
</div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">
SAMLObjectBuilder<org.opensaml.saml2.ecp.Response>
ecpResponseBuilder =
(SAMLObjectBuilder<org.opensaml.saml2.ecp.Response>)
builderFactory.getBuilder(org.opensaml.saml2.ecp.Response.DEFAULT_ELEMENT_NAME);</span></div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">
org.opensaml.saml2.ecp.Response
ecpResponse =
ecpResponseBuilder.buildObject();</span></div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">
ecpResponse.setSOAP11MustUnderstand(true);</span></div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">
ecpResponse.setSOAP11Actor(org.opensaml.saml2.ecp.Response.SOAP11_ACTOR_NEXT);</span></div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">
ecpResponse.setAssertionConsumerServiceURL("<a rel="nofollow" target="_blank" href="https://localhost:8443/spring-security-saml2-sample">https://localhost:8443/sp_URL</a>");
</span></div>
<div class="yiv848773346MsoNormal"><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;">
SOAPHelper.addHeaderBlock(messageContext,
ecpResponse);</span></div>
<div class="yiv848773346MsoNormal"><span style="font-size:10.0pt;font-family:Consolas;color:#4F81BD;"> </span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
Off-hand, this approach looks more or less correct, at least in
broad strokes. But since it isn't working, there must be something
subtly wrong. I have to run out the door soon, but I will later try
and take a closer look and see if I can spot what it is.<br>
<br>
<br>
<blockquote type="cite">
<div style="color:#000;background-color:#fff;font-family:tahoma, new york, times, serif;font-size:10pt;">
<div style="font-family:tahoma, new york, times, serif;font-size:10pt;">
<div style="font-family:times new roman, new york, times, serif;font-size:12pt;">
<div id="yiv848773346">
<div>
<div style="color:#000;background-color:#fff;font-family:tahoma, new york, times, serif;font-size:10pt;">
<div style="font-family:tahoma, new york, times, serif;font-size:10pt;">
<div style="font-family:times new roman, new york, times, serif;font-size:12pt;">
<div id="yiv848773346">
<div>
<div style="color:#000;background-color:#fff;font-family:tahoma, new york, times, serif;font-size:10pt;">
<div class="yiv848773346MsoNormal"><span style="font-size:10.0pt;font-family:Consolas;">And
another
way:</span></div>
<div class="yiv848773346MsoNormal" style="text-indent:.5in;"><span style="font-size:10.0pt;font-family:Consolas;color:#953735;">SOAPObjectBuilder<Envelope>
envelopeBuilder
= <u>(SOAPObjectBuilder<Envelope>)
builderFactory.getBuilder(Envelope.<i>DEFAULT_ELEMENT_NAME</i>)</u>;</span></div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#953735;">
Envelope envelope =
envelopeBuilder.buildObject();
</span></div>
<span style="font-size:10.0pt;font-family:Consolas;color:#953735;">
</span>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#953735;"> SOAPObjectBuilder<Header>
headerBuilder
= <u>(SOAPObjectBuilder<Header>)
builderFactory.getBuilder(Header.<i>DEFAULT_ELEMENT_NAME</i>)</u>;</span></div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#953735;">
Header header =
headerBuilder.buildObject(); </span></div>
<span style="font-size:10.0pt;font-family:Consolas;color:#953735;"> </span>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#953735;"> SAMLObjectBuilder<org.opensaml.saml2.ecp.Response>
ecpResponseBuilder
= <u>(SAMLObjectBuilder<org.opensaml.saml2.ecp.Response>)
builderFactory.getBuilder(org.opensaml.saml2.ecp.Response.<i>DEFAULT_ELEMENT_NAME</i>)</u>;</span></div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#953735;">
org.opensaml.saml2.ecp.Response
ecpResponse =
ecpResponseBuilder.buildObject();</span></div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#953735;">
ecpResponse.setSOAP11MustUnderstand(<b>true</b>);</span></div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#953735;">
ecpResponse.setSOAP11Actor(org.opensaml.saml2.ecp.Response.<i>SOAP11_ACTOR_NEXT</i>);</span></div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#953735;">
ecpResponse.setAssertionConsumerServiceURL("<a rel="nofollow" target="_blank" href="https://localhost:8443/spring-security-saml2-sample">https://localhost:8443/sp</a>");</span><span style="font-size:10.0pt;font-family:Consolas;color:#953735;">
</span>
</div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#953735;">
header.getUnknownXMLObjects().add(ecpResponse);</span></div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#953735;">
envelope.setHeader(header);</span><span style="font-size:10.0pt;font-family:Consolas;color:#953735;"> </span>
</div>
<div class="yiv848773346MsoNormal" style=""><span style="font-size:10.0pt;font-family:Consolas;color:#953735;"> <span style="background:yellow;">messageContext</span>.setOutboundMessage(envelope);</span></div>
<div class="yiv848773346MsoNormal"><span style="font-size:10.0pt;font-family:Consolas;color:#953735;">
<u><span style="background:yellow;">messageContext</span>.setOutboundSAMLMessage(authResponse)</u>;
</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
<br>
<br>
This also looks off-hand correct, but again there must be some
trivial thing that is being omitted or something (or possibly we
have a bug somewhere.<br>
<br>
</div>
</div><br>--<br>To unsubscribe from this list send an email to <a ymailto="mailto:dev-unsubscribe@shibboleth.net" href="mailto:dev-unsubscribe@shibboleth.net">dev-unsubscribe@shibboleth.net</a><br><br> </div> </div> </div></body></html>