Skip to content

Instantly share code, notes, and snippets.

@yaronn
yaronn / ws.js
Created April 21, 2012 17:43
ws.js sample
var ws = require('ws.js')
, Http = ws.Http
, Security = ws.Security
, UsernameToken = ws.UsernameToken
var request = '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">' +
'<Header />' +
'<Body>' +
'<EchoString xmlns="http://tempuri.org/">' +
'<s>123</s>' +
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<Header>
<o:Security>
<u:Timestamp>
<u:Created>2012-02-26T11:03:40Z</u:Created>
<u:Expires>2012-02-26T11:08:40Z</u:Expires>
</u:Timestamp>
<o:UsernameToken>
<o:Username>yaron</o:Username>
<o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">1234</o:Password>
if (n.MoveToFollowing("Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"))
{
n.DeleteSelf();
}
<security authenticationMode="UserNameOverTransport"
enableUnsecuredResponse="true"
includeTimestamp="false">
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<callback s:mustUnderstand="1">http://www.server.com/</callback>
</s:Header>
<s:Body />
</s:Envelope>
[System.ServiceModel.ServiceBehavior(ValidateMustUnderstand = false)]
public class MyService : IServiceContract
{
// ...
}
public class ValidateMustUnderstandElement : BehaviorExtensionElement
{
public override Type BehaviorType
{
get { return typeof (MustUnderstandBehavior); }
}
protected override object CreateBehavior()
{
return new MustUnderstandBehavior(false);
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="validateMustUnderstand" type="WCF_Self_Hosted_Service48.ValidateMustUnderstandElement, WCF Self Hosted Service48, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
...
<behaviors>
<endpointBehaviors>
<behavior name="NewBehavior">
<validateMustUnderstand />
</behavior>
</endpointBehaviors>
...
<wsdl:port name="BasicHttpBinding_IService" binding="tns:BasicHttpBinding_IService">
<wsdl:documentation>crearted on 05/05/2012 21:08:13</wsdl:documentation>