Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / August 2004

Tip: Looking for answers? Try searching our database.

signing message element by id / no namespace

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stewart Bourke - 09 Jul 2004 10:27 GMT
wse 1.01, vs.net 2003 c#

IS it possible to sign an element of a soap message using an Id attribute
without prefixing the Id attribute with a namespace.  wse seems to call for
a namespace referring to ws-utility, but I need to be able to sign the Id
without the namespace - as the webservice I am consuming will not accept the
Id with a NS prefix:

Currently I have:

   <soap:Header>
     <Operation d3p1:Id="MsgOperation"
xmlns:d3p1="http://schemas.xmlsoap.org/ws/2002/07/utility"
xmlns="http://www.ros.ie/schemas/service/">Inbox/List</Operation>
   </soap:Header>
   <soap:Body wsu:Id="MsgBody"
xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility">
     <DocumentSearch xmlns="http://www.ros.ie/schemas/inbox/" />
   </soap:Body>

but I need:

   <soap:Header>
     <Operation Id="MsgOperation"
xmlns="http://www.ros.ie/schemas/service/">Inbox/List</Operation>"
   </soap:Header>
   <soap:Body Id="MsgBody" >
     <DocumentSearch xmlns="http://www.ros.ie/schemas/inbox/" />
   </soap:Body>

Thanks,

Stewart Bourke
Stewart Bourke - 12 Jul 2004 17:48 GMT
I take it that this is not possible with wse...

> wse 1.01, vs.net 2003 c#
>
[quoted text clipped - 29 lines]
>
> Stewart Bourke
Lucien - 14 Jul 2004 22:40 GMT
Try without namespace. I think it still will locate it (if it can't find
with namespace I believe it defaults to unqualified Id attribute).
Another way is to use xmlns=""...

> I take it that this is not possible with wse...
>
[quoted text clipped - 33 lines]
> >
> > Stewart Bourke
Stewart Bourke - 14 Jul 2004 23:34 GMT
Unfortunately I get 'malformed reference' when I try to add the attribute
without a namespace.

Maybe I am  misunderstanding what you are suggesting.  What do you mean
'xmlns='''..  In the class defintion - in my proxy code?

Thanks,

Stewart Bourke

> Try without namespace. I think it still will locate it (if it can't find
> with namespace I believe it defaults to unqualified Id attribute).
[quoted text clipped - 39 lines]
> > >
> > > Stewart Bourke
Lucien - 15 Jul 2004 00:42 GMT
I tried and it worked for me: the only change I made was to remove namespace
in the header definition:

public class OrderTimeHeader : System.Web.Services.Protocols.SoapHeader
{
[XmlAttribute("Id")]
public String Id;
...

I didn't change the client code:
  serviceProxy.OrderTimeHeaderValue = header;
  SignatureReference soapRef = new
SignatureReference("#Id:05d2518d-d6db-481f-846d-2e8872b6e56d");
  soapRef.AddTransform(new XmlDsigExcC14NTransform());
  MessageSignature s = new MessageSignature( token );
  s.AddReference(soapRef);
  serviceProxy.RequestSoapContext.Security.Elements.Add( s );
...

On the wire I did see now no namespace for the Id attribute.

> Unfortunately I get 'malformed reference' when I try to add the attribute
> without a namespace.
[quoted text clipped - 54 lines]
> > > >
> > > > Stewart Bourke
Stewart Bourke - 15 Jul 2004 14:48 GMT
Lucien,

I tried leaving out the NS and I gat a 'malformed reference' when trying to
sign.

1.  I am using wse1 - did you try this in wse1 or 2?

2.  The reason I want to stay with wse1 is the security namespaces I need to
refer to - dy you know if it is, for example,
xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" and
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"
/> etc..

Is this possible with wse2?

Also, would it be possible to send you a mail directly, as I would like to
have a very brief conversation offline?

Thanks,

Stewart Bourke = email:   Stewart_at_eircom.net (replace _at_ with @)

> I tried and it worked for me: the only change I made was to remove namespace
> in the header definition:
[quoted text clipped - 79 lines]
> > > > >
> > > > > Stewart Bourke
Lucien - 15 Jul 2004 17:17 GMT
Sorry wasn't aware this was V1.0. I think this was a change in v2 to default
to unqualified attribute if Id is not found.

The namespace changed for wsu to
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd
(not for the CanonicalizationMethod).

> Lucien,
>
[quoted text clipped - 84 lines]
> > > > > >       <Operation d3p1:Id="MsgOperation"
> > > > > > xmlns:d3p1="http://schemas.xmlsoap.org/ws/2002/07/utility"

xmlns="http://www.ros.ie/schemas/service/">Inbox/List</Operation>
> > > > > >     </soap:Header>
> > > > > >     <soap:Body wsu:Id="MsgBody"
[quoted text clipped - 6 lines]
> > > > > >     <soap:Header>
> > > > > >       <Operation Id="MsgOperation"

xmlns="http://www.ros.ie/schemas/service/">Inbox/List</Operation>"
> > > > > >     </soap:Header>
> > > > > >     <soap:Body Id="MsgBody" >
[quoted text clipped - 4 lines]
> > > > > >
> > > > > > Stewart Bourke
Stewart Bourke - 15 Jul 2004 20:18 GMT
The namespace change is actually my problem here - can I use the old wse1
namespaces in wse2?

Thanks,

Stewart Bourke

> Sorry wasn't aware this was V1.0. I think this was a change in v2 to default
> to unqualified attribute if Id is not found.
>
> The namespace changed for wsu to

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd
> (not for the CanonicalizationMethod).
>
[quoted text clipped - 120 lines]
> > > > > > >
> > > > > > > Stewart Bourke
Lucien - 15 Jul 2004 21:54 GMT
Of course you can set the namespace for the header Id attribute yourself but
not Id attributes created by WSE 2.0.
However using the old utility namespace would cause WSE 2.0 not to find this
attribute and it would fail unless you use no namespace at all for this
attribute.

Actually if you would add a second Id attribute with your namespace for that
header it should work (provided you're not signing any other elements that
also need to be changed this way).

> The namespace change is actually my problem here - can I use the old wse1
> namespaces in wse2?
[quoted text clipped - 8 lines]
> >
> > The namespace changed for wsu to

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd
> > (not for the CanonicalizationMethod).
> >
[quoted text clipped - 126 lines]
> > > > > > > >
> > > > > > > > Stewart Bourke
Stewart Bourke - 16 Jul 2004 09:40 GMT
Interesting approach.

In fact I do need to sign two sections - one in the header and one on the
body - would this still work?

The soap message I need to send is:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<soap:Header>
<Operation Id="MsgOperation"
xmlns="http://www.ros.ie/schemas/service/">Inbox/List</Operation>
</soap:Header>

<soap:Body Id="MsgOperation" >
<DocumentSearch xmlns="http://www.ros.ie/schemas/inbox/" />
</soap:Body>
</soap:Envelope>

The two IDs = MsgOperation and MsgBody need to be signed, and they both must
not have any prefixes?

Would your suggested approach work in this case?

Thanks...

> Of course you can set the namespace for the header Id attribute yourself but
> not Id attributes created by WSE 2.0.
[quoted text clipped - 18 lines]
> > >
> > > The namespace changed for wsu to

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1
.0.xsd
> > > (not for the CanonicalizationMethod).
> > >
[quoted text clipped - 136 lines]
> > > > > > > > >
> > > > > > > > > Stewart Bourke
Lucien - 16 Jul 2004 23:13 GMT
My idea was to add a 2nd attribute without the namespace. I don't know if
you access to the soap:body using the ASMX proxy as far as I know but if you
use WSE 2.0 you can use SoapClient with soapEnvelope input which has direct
access to the soap:body. Note that WSE will add an wsu:Id automatically to
the soap:Body (in the wsu namespace) when you sign unless it's already
there. Here's code example based on the stock sample that comes with V2.0:

// define your messaging client (see TCP/HTTP sample) how to do this
MySoapClient mySoapClient = new MySoapClient(new
Uri(http://localhost/StockService/StockService.asmx));
SoapEnvelope env = new SoapEnvelope();
env.Body.InnerXml = "<StockQuoteRequest
xmlns=\"http://stockservice.contoso.com/wse/samples/2003/06\"><symbols><Symb
ol>FABRIKAM</Symbol><Symbol>CONTOSO</Symbol></symbols></StockQuoteRequest>";

// sign
X509SecurityToken token = GetEncryptionToken();
env.Context.Security.Tokens.Add(token);
MessageSignature s = new MessageSignature(token);

// only sign soap body
s.SignatureOptions = SignatureOptions.IncludeSoapBody;

// add here reference to your header
//s.AddReference

env.Context.Security.Elements.Add(s);
XmlAttribute attr = env.Body.OwnerDocument.CreateAttribute("Id");
// add here your unique ID
attr.Value = "myIdValue";
// add second Id for WSE with same value
XmlAttribute attr2 =
env.Body.OwnerDocument.CreateAttribute(WSUtility.Prefix,"Id",
WSUtility.NamespaceURI);
attr2.Value = "myIdValue";
env.Body.Attributes.Append(attr2);

// Send response
SoapEnvelope response =
mySoapClient.GenericRequestResponse("http://stockservice.contoso.com/wse/sam
ples/2003/06/StockQuoteRequest",env);

> Interesting approach.
>
[quoted text clipped - 50 lines]
> > > >
> > > > The namespace changed for wsu to

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1
> .0.xsd
> > > > (not for the CanonicalizationMethod).
[quoted text clipped - 115 lines]
> > > > > > > > > >     <soap:Header>
> > > > > > > > > >       <Operation d3p1:Id="MsgOperation"

xmlns:d3p1="http://schemas.xmlsoap.org/ws/2002/07/utility"

> > > > xmlns="http://www.ros.ie/schemas/service/">Inbox/List</Operation>
> > > > > > > > > >     </soap:Header>
> > > > > > > > > >     <soap:Body wsu:Id="MsgBody"

xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility">
> > > > > > > > > >       <DocumentSearch
> > xmlns="http://www.ros.ie/schemas/inbox/"
[quoted text clipped - 17 lines]
> > > > > > > > > >
> > > > > > > > > > Stewart Bourke
Stewart Bourke - 23 Jul 2004 12:08 GMT
Lucien,

I have tried as you suggested, and whilst it appeared to have created my Id
attributes with no prefix, I appear to have a number of issues, which have
been intriduced by my move to we2.  So, I have some specific questions:

1.  The wsse namespace is now:
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
ty-secext-1.0.xsd"

Can I use the following NS in wse2?

<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext">

2.  Can I remove the wsa elements?  They are not allowed in the service I
wish to call.

3.   In wse1 I did the following:

outputFilters.Remove(typeof(Microsoft.Web.Services2.Routing.RoutingOutputFil
ter));
outputFilters.Remove(typeof(Microsoft.Web.Services2.Timestamp.TimestampOutpu
tFilter));

to remove filters.  How do I do this in wse2?

I know the service I am calling is not a full wsse-compliant service, but I
cannot change it - hence these questions..

Thanks,

> My idea was to add a 2nd attribute without the namespace. I don't know if
> you access to the soap:body using the ASMX proxy as far as I know but if you
[quoted text clipped - 8 lines]
> SoapEnvelope env = new SoapEnvelope();
> env.Body.InnerXml = "<StockQuoteRequest

xmlns=\"http://stockservice.contoso.com/wse/samples/2003/06\"><symbols><Symb

ol>FABRIKAM</Symbol><Symbol>CONTOSO</Symbol></symbols></StockQuoteRequest>";

> // sign
> X509SecurityToken token = GetEncryptionToken();
[quoted text clipped - 20 lines]
> // Send response
> SoapEnvelope response =

mySoapClient.GenericRequestResponse("http://stockservice.contoso.com/wse/sam
> ples/2003/06/StockQuoteRequest",env);
>
[quoted text clipped - 57 lines]
> > > > >
> > > > > The namespace changed for wsu to

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1
> > .0.xsd
> > > > > (not for the CanonicalizationMethod).
[quoted text clipped - 48 lines]
> > > > > > >    serviceProxy.OrderTimeHeaderValue = header;
> > > > > > >    SignatureReference soapRef = new

SignatureReference("#Id:05d2518d-d6db-481f-846d-2e8872b6e56d");
> > > > > > >    soapRef.AddTransform(new XmlDsigExcC14NTransform());
> > > > > > >    MessageSignature s = new MessageSignature( token );
[quoted text clipped - 100 lines]
> > > > > > > > > > >
> > > > > > > > > > > Stewart Bourke
Lucien - 26 Jul 2004 22:07 GMT
You can't change the namespaces unless again you use a filter and manipulate
the message. Take a look at the customFilter. If you run the filter last you
can change the namespace and remove the headers.

PS I don't understand why you can't have wsa headers that are not marked
MustUnderstand equal true. Services should not reject these headers unless
they're marked as true. Which product is the service based on?

Lucien

> Lucien,
>
[quoted text clipped - 3 lines]
>
> 1.  The wsse namespace is now:

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
> ty-secext-1.0.xsd"
>
[quoted text clipped - 6 lines]
>
> 3.   In wse1 I did the following:

outputFilters.Remove(typeof(Microsoft.Web.Services2.Routing.RoutingOutputFil
> ter));

outputFilters.Remove(typeof(Microsoft.Web.Services2.Timestamp.TimestampOutpu
> tFilter));
>
[quoted text clipped - 19 lines]
> > SoapEnvelope env = new SoapEnvelope();
> > env.Body.InnerXml = "<StockQuoteRequest

xmlns=\"http://stockservice.contoso.com/wse/samples/2003/06\"><symbols><Symb

ol>FABRIKAM</Symbol><Symbol>CONTOSO</Symbol></symbols></StockQuoteRequest>";

> > // sign
> > X509SecurityToken token = GetEncryptionToken();
[quoted text clipped - 20 lines]
> > // Send response
> > SoapEnvelope response =

mySoapClient.GenericRequestResponse("http://stockservice.contoso.com/wse/sam
> > ples/2003/06/StockQuoteRequest",env);
> >
[quoted text clipped - 63 lines]
> > > > > >
> > > > > > The namespace changed for wsu to

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1
> > > .0.xsd
> > > > > > (not for the CanonicalizationMethod).
[quoted text clipped - 133 lines]
> > > > > > > > > > > >
> > xmlns:d3p1="http://schemas.xmlsoap.org/ws/2002/07/utility"

xmlns="http://www.ros.ie/schemas/service/">Inbox/List</Operation>
> > > > > > > > > > > >     </soap:Header>
> > > > > > > > > > > >     <soap:Body wsu:Id="MsgBody"
[quoted text clipped - 9 lines]
> > > > > > > > > > > >     <soap:Header>
> > > > > > > > > > > >       <Operation Id="MsgOperation"

xmlns="http://www.ros.ie/schemas/service/">Inbox/List</Operation>"
> > > > > > > > > > > >     </soap:Header>
> > > > > > > > > > > >     <soap:Body Id="MsgBody" >
[quoted text clipped - 6 lines]
> > > > > > > > > > > >
> > > > > > > > > > > > Stewart Bourke
Stewart Bourke - 26 Jul 2004 23:02 GMT
Lucien,

The service is a java-based service build using the Baltimore BeTrusted
tools...

I'll try yopur suggestions.

Regards,

Stewart Bourke

> You can't change the namespaces unless again you use a filter and manipulate
> the message. Take a look at the customFilter. If you run the filter last you
[quoted text clipped - 14 lines]
> >
> > 1.  The wsse namespace is now:

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
> > ty-secext-1.0.xsd"
> >
[quoted text clipped - 6 lines]
> >
> > 3.   In wse1 I did the following:

outputFilters.Remove(typeof(Microsoft.Web.Services2.Routing.RoutingOutputFil
> > ter));

outputFilters.Remove(typeof(Microsoft.Web.Services2.Timestamp.TimestampOutpu
> > tFilter));
> >
[quoted text clipped - 23 lines]
> > > SoapEnvelope env = new SoapEnvelope();
> > > env.Body.InnerXml = "<StockQuoteRequest

xmlns=\"http://stockservice.contoso.com/wse/samples/2003/06\"><symbols><Symb

ol>FABRIKAM</Symbol><Symbol>CONTOSO</Symbol></symbols></StockQuoteRequest>";

> > > // sign
> > > X509SecurityToken token = GetEncryptionToken();
[quoted text clipped - 20 lines]
> > > // Send response
> > > SoapEnvelope response =

mySoapClient.GenericRequestResponse("http://stockservice.contoso.com/wse/sam
> > > ples/2003/06/StockQuoteRequest",env);
> > >
[quoted text clipped - 70 lines]
> > > > > > >
> > > > > > > The namespace changed for wsu to

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1
> > > > .0.xsd
> > > > > > > (not for the CanonicalizationMethod).
[quoted text clipped - 168 lines]
> > > > > > > > > > > > >
> > > > > > > > > > > > > Stewart Bourke
Stewart Bourke - 28 Jul 2004 15:34 GMT
Lucien,

I have tried to do as you suggested with a CustomFilter: but it appears from
the work I need to do to make the message compliant with the server, there
is simply too much to do.

So, I have the following questions:

1.  Is it possible to construct a soap message directly from scratch.  IF
so,  would you have any poi nters on how to do this.

2.  Can I then sign portions of my message directly, without using the full
wse capabilities.

From what I can see, my message structure if perfect before adding the
security stuff.  I need the message-building elemtns of wse2 (i.,e. the
ability to have an attribute without the NS prefix) with the
signature-handling namespaces and strucutres of wse1.  IS this possible?

Thanks,

> You can't change the namespaces unless again you use a filter and manipulate
> the message. Take a look at the customFilter. If you run the filter last you
[quoted text clipped - 14 lines]
> >
> > 1.  The wsse namespace is now:

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
> > ty-secext-1.0.xsd"
> >
[quoted text clipped - 6 lines]
> >
> > 3.   In wse1 I did the following:

outputFilters.Remove(typeof(Microsoft.Web.Services2.Routing.RoutingOutputFil
> > ter));

outputFilters.Remove(typeof(Microsoft.Web.Services2.Timestamp.TimestampOutpu
> > tFilter));
> >
[quoted text clipped - 23 lines]
> > > SoapEnvelope env = new SoapEnvelope();
> > > env.Body.InnerXml = "<StockQuoteRequest

xmlns=\"http://stockservice.contoso.com/wse/samples/2003/06\"><symbols><Symb

ol>FABRIKAM</Symbol><Symbol>CONTOSO</Symbol></symbols></StockQuoteRequest>";

> > > // sign
> > > X509SecurityToken token = GetEncryptionToken();
[quoted text clipped - 20 lines]
> > > // Send response
> > > SoapEnvelope response =

mySoapClient.GenericRequestResponse("http://stockservice.contoso.com/wse/sam
> > > ples/2003/06/StockQuoteRequest",env);
> > >
[quoted text clipped - 70 lines]
> > > > > > >
> > > > > > > The namespace changed for wsu to

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1
> > > > .0.xsd
> > > > > > > (not for the CanonicalizationMethod).
[quoted text clipped - 168 lines]
> > > > > > > > > > > > >
> > > > > > > > > > > > > Stewart Bourke
Lucien - 28 Jul 2004 17:30 GMT
I still think customFilter is quickest way. All you need to do is change the
WSSE namespace in all places in the soap envelope and remove the wsu prefix
on Id attributes and the addressing headers. That should be quite easy
(basic XML manipulation). For instance adding this to the customFilter
removes all WSAddressing headers:

  // remove addressing nodes
  for (int i = envelope.Header.ChildNodes.Count-1; i >= 0;  i--)
  {
   if ( envelope.Header.ChildNodes[i].NamespaceURI ==
Microsoft.Web.Services2.Addressing.WSAddressing.NamespaceURI )
   {
    envelope.Header.RemoveChild(envelope.Header.ChildNodes[i]);
   }
  }

> Lucien,
>
[quoted text clipped - 38 lines]
> > >
> > > 1.  The wsse namespace is now:

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
> > > ty-secext-1.0.xsd"
> > >
[quoted text clipped - 8 lines]
> > >
> > > 3.   In wse1 I did the following:

outputFilters.Remove(typeof(Microsoft.Web.Services2.Routing.RoutingOutputFil
> > > ter));

outputFilters.Remove(typeof(Microsoft.Web.Services2.Timestamp.TimestampOutpu
> > > tFilter));
> > >
[quoted text clipped - 26 lines]
> > > > SoapEnvelope env = new SoapEnvelope();
> > > > env.Body.InnerXml = "<StockQuoteRequest

xmlns=\"http://stockservice.contoso.com/wse/samples/2003/06\"><symbols><Symb

ol>FABRIKAM</Symbol><Symbol>CONTOSO</Symbol></symbols></StockQuoteRequest>";

> > > > // sign
> > > > X509SecurityToken token = GetEncryptionToken();
[quoted text clipped - 20 lines]
> > > > // Send response
> > > > SoapEnvelope response =

mySoapClient.GenericRequestResponse("http://stockservice.contoso.com/wse/sam
> > > > ples/2003/06/StockQuoteRequest",env);
> > > >
[quoted text clipped - 73 lines]
> > > > > > > >
> > > > > > > > The namespace changed for wsu to

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1
> > > > > .0.xsd
> > > > > > > > (not for the CanonicalizationMethod).
[quoted text clipped - 60 lines]
> > > > > > > > > >    MessageSignature s = new MessageSignature( token );
> > > > > > > > > >    s.AddReference(soapRef);

serviceProxy.RequestSoapContext.Security.Elements.Add(
> > s );
> > > > > > > > > > ...
[quoted text clipped - 113 lines]
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Stewart Bourke
Stewart Bourke - 28 Jul 2004 18:27 GMT
Ok - thanks - that worked like a charm..

When I try now to remove also the wsu stuff, it is not removed:

for (int i = envelope.Header.ChildNodes.Count-1; i >= 0; i--)
{
if ( envelope.Header.ChildNodes[i].NamespaceURI ==
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-
1.0.xsd" )
{
envelope.Header.RemoveChild(envelope.Header.ChildNodes[i]);
}
}

It maybe because it is down an additional node level?

Also, I now need to change the various NS involved, and I would appreciate
it if you had a little code snippet on how to do this.  for example, I need
to change:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
ty-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurit
y-utility-1.0.xsd">

to show

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"

xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext" <-- this needs to
be changed...

xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurit
y-utility-1.0.xsd">

<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext">

> I still think customFilter is quickest way. All you need to do is change the
> WSSE namespace in all places in the soap envelope and remove the wsu prefix
[quoted text clipped - 62 lines]
> > > >
> > > > 1.  The wsse namespace is now:

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
> > > > ty-secext-1.0.xsd"
> > > >
[quoted text clipped - 9 lines]
> > > >
> > > > 3.   In wse1 I did the following:

outputFilters.Remove(typeof(Microsoft.Web.Services2.Routing.RoutingOutputFil
> > > > ter));

outputFilters.Remove(typeof(Microsoft.Web.Services2.Timestamp.TimestampOutpu
> > > > tFilter));
> > > >
[quoted text clipped - 29 lines]
> > > > > SoapEnvelope env = new SoapEnvelope();
> > > > > env.Body.InnerXml = "<StockQuoteRequest

xmlns=\"http://stockservice.contoso.com/wse/samples/2003/06\"><symbols><Symb

ol>FABRIKAM</Symbol><Symbol>CONTOSO</Symbol></symbols></StockQuoteRequest>";

> > > > > // sign
> > > > > X509SecurityToken token = GetEncryptionToken();
[quoted text clipped - 20 lines]
> > > > > // Send response
> > > > > SoapEnvelope response =

mySoapClient.GenericRequestResponse("http://stockservice.contoso.com/wse/sam
> > > > > ples/2003/06/StockQuoteRequest",env);
> > > > >
[quoted text clipped - 17 lines]
> > > > > > <soap:Header>
> > > > > > <Operation Id="MsgOperation"

xmlns="http://www.ros.ie/schemas/service/">Inbox/List</Operation>
> > > > > > </soap:Header>
> > > > > >
[quoted text clipped - 55 lines]
> > > > > > > > >
> > > > > > > > > The namespace changed for wsu to

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1
> > > > > > .0.xsd
> > > > > > > > > (not for the CanonicalizationMethod).
[quoted text clipped - 21 lines]
> > > > > > > > > to
> > > > > > > > > > refer to - dy you know if it is, for example,

xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"
> > and
> > > > > > > > > > <CanonicalizationMethod
[quoted text clipped - 162 lines]
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Stewart Bourke
Lucien - 28 Jul 2004 19:34 GMT
What do you mean with wsu stuff? You mean the timestamp header? Yes that's 1
level down under the Security node. Better to use XPath (SelectSingleNode)
to locate it. You can capture the message using built-in trace (in VS right
click on WS Settings and enable diagnostics).

By the way I would also talk to Baltimore techn. to see if they fixed the
mustunderstand bug (they must not fault if mustUnderstand is not set to
true). And maybe the'll have a release for the latest WS-Security spec.

> Ok - thanks - that worked like a charm..
>
[quoted text clipped - 3 lines]
> {
> if ( envelope.Header.ChildNodes[i].NamespaceURI ==

"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-
> 1.0.xsd" )
> {
[quoted text clipped - 12 lines]
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
> ty-secext-1.0.xsd"

xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurit
> y-utility-1.0.xsd">
>
[quoted text clipped - 7 lines]
> xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext" <-- this needs to
> be changed...

xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurit
> y-utility-1.0.xsd">
>
[quoted text clipped - 74 lines]
> > > > >
> > > > > 1.  The wsse namespace is now:

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
> > > > > ty-secext-1.0.xsd"
> > > > >
[quoted text clipped - 9 lines]
> > > > >
> > > > > 3.   In wse1 I did the following:

outputFilters.Remove(typeof(Microsoft.Web.Services2.Routing.RoutingOutputFil
> > > > > ter));

outputFilters.Remove(typeof(Microsoft.Web.Services2.Timestamp.TimestampOutpu
> > > > > tFilter));
> > > > >
[quoted text clipped - 33 lines]
> > > > > > SoapEnvelope env = new SoapEnvelope();
> > > > > > env.Body.InnerXml = "<StockQuoteRequest

xmlns=\"http://stockservice.contoso.com/wse/samples/2003/06\"><symbols><Symb

ol>FABRIKAM</Symbol><Symbol>CONTOSO</Symbol></symbols></StockQuoteRequest>";

> > > > > > // sign
> > > > > > X509SecurityToken token = GetEncryptionToken();
[quoted text clipped - 20 lines]
> > > > > > // Send response
> > > > > > SoapEnvelope response =

mySoapClient.GenericRequestResponse("http://stockservice.contoso.com/wse/sam
> > > > > > ples/2003/06/StockQuoteRequest",env);
> > > > > >
[quoted text clipped - 83 lines]
> > > > > > > > > >
> > > > > > > > > > The namespace changed for wsu to

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1
> > > > > > > .0.xsd
> > > > > > > > > > (not for the CanonicalizationMethod).
[quoted text clipped - 200 lines]
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Stewart Bourke
Stewart Bourke - 04 Aug 2004 01:17 GMT
OK, this one has me.  I cannot seem to locate it using xpath.  Would you
have a sample of how to do it?

Would you also have a sample of how to change a namespace within an xml
element?

w.r.t. the comments about baltimore - unfortunately the webservice provider
(the irish tax authorities) have said they have no plans to u/g their
webservices - they are sticking with what is published at present - so we
are stuck with them...

Thanks,

> What do you mean with wsu stuff? You mean the timestamp header? Yes that's 1
> level down under the Security node. Better to use XPath (SelectSingleNode)
[quoted text clipped - 12 lines]
> > {
> > if ( envelope.Header.ChildNodes[i].NamespaceURI ==

"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-
> > 1.0.xsd" )
> > {
[quoted text clipped - 13 lines]
> > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
> > ty-secext-1.0.xsd"

xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurit
> > y-utility-1.0.xsd">
> >
[quoted text clipped - 8 lines]
> to
> > be changed...

xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurit
> > y-utility-1.0.xsd">
> >
[quoted text clipped - 80 lines]
> > > > > >
> > > > > > 1.  The wsse namespace is now:

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
> > > > > > ty-secext-1.0.xsd"
> > > > > >
[quoted text clipped - 9 lines]
> > > > > >
> > > > > > 3.   In wse1 I did the following:

outputFilters.Remove(typeof(Microsoft.Web.Services2.Routing.RoutingOutputFil
> > > > > > ter));

outputFilters.Remove(typeof(Microsoft.Web.Services2.Timestamp.TimestampOutpu
> > > > > > tFilter));
> > > > > >
[quoted text clipped - 35 lines]
> > > > > > > SoapEnvelope env = new SoapEnvelope();
> > > > > > > env.Body.InnerXml = "<StockQuoteRequest

xmlns=\"http://stockservice.contoso.com/wse/samples/2003/06\"><symbols><Symb

ol>FABRIKAM</Symbol><Symbol>CONTOSO</Symbol></symbols></StockQuoteRequest>";

> > > > > > > // sign
> > > > > > > X509SecurityToken token = GetEncryptionToken();
[quoted text clipped - 21 lines]
> > > > > > > // Send response
> > > > > > > SoapEnvelope response =

mySoapClient.GenericRequestResponse("http://stockservice.contoso.com/wse/sam
> > > > > > > ples/2003/06/StockQuoteRequest",env);
> > > > > > >
[quoted text clipped - 87 lines]
> > > > > > > > > > >
> > > > > > > > > > > The namespace changed for wsu to

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1
> > > > > > > > .0.xsd
> > > > > > > > > > > (not for the CanonicalizationMethod).
[quoted text clipped - 140 lines]
> > > > > > > > > > in
> > > > > > > > > > > > > > message

news:uKXJadZZEHA.2840@TK2MSFTNGP11.phx.gbl...
> > > > > > > > > > > > > > > > > wse 1.01, vs.net 2003 c#
> > > > > > > > > > > > > > > > >
[quoted text clipped - 62 lines]
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Stewart Bourke
Lucien - 06 Aug 2004 18:58 GMT
Something like this (to verify as I didn't test this but there's doc on MSN
and VS help for SelectSingleNode/XPath):

XmlNamespaceManager nsm = new
XmlNamespaceManager(requestContext.Envelope.NameTable);
// add your prefixes here for your xpath expression
nsm.AddNamespace("wsse", WSSecurity.NamespaceURI);
nsm.AddNamespace("wsu", WSUtility.NamespaceURI);
node = envelope.Header.SelectSingleNode("//wsse:Security/wsu:Timestamp",
nsm);

Although I actually think you probably need to select just the Security
header and then loop through the children. So you might want to remove the
wsu:Timestamp from the expression depending how you will delete the node.

Another example and not so recommended way since it ignores namespace:

    node =
envelope.SelectSingleNode("//*[local-name()='Envelope']/*[local-name()='Head
er']/*[local-name()='Security']");

There are also tools on the web for XPath evaluation to test this first.

> OK, this one has me.  I cannot seem to locate it using xpath.  Would you
> have a sample of how to do it?
[quoted text clipped - 27 lines]
> > > {
> > > if ( envelope.Header.ChildNodes[i].NamespaceURI ==

"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-
> > > 1.0.xsd" )
> > > {
[quoted text clipped - 14 lines]
> > > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > > xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
> > > ty-secext-1.0.xsd"

xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurit
> > > y-utility-1.0.xsd">
> > >
[quoted text clipped - 8 lines]
> > to
> > > be changed...

xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurit
> > > y-utility-1.0.xsd">
> > >
[quoted text clipped - 87 lines]
> > > > > > >
> > > > > > > 1.  The wsse namespace is now:

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecuri
> > > > > > > ty-secext-1.0.xsd"
> > > > > > >
[quoted text clipped - 9 lines]
> > > > > > >
> > > > > > > 3.   In wse1 I did the following:

outputFilters.Remove(typeof(Microsoft.Web.Services2.Routing.RoutingOutputFil
> > > > > > > ter));

outputFilters.Remove(typeof(Microsoft.Web.Services2.Timestamp.TimestampOutpu
> > > > > > > tFilter));
> > > > > > >
[quoted text clipped - 38 lines]
> > > > > > > > SoapEnvelope env = new SoapEnvelope();
> > > > > > > > env.Body.InnerXml = "<StockQuoteRequest

xmlns=\"http://stockservice.contoso.com/wse/samples/2003/06\"><symbols><Symb

ol>FABRIKAM</Symbol><Symbol>CONTOSO</Symbol></symbols></StockQuoteRequest>";

> > > > > > > > // sign
> > > > > > > > X509SecurityToken token = GetEncryptionToken();
[quoted text clipped - 14 lines]
> > > > > > > > // add second Id for WSE with same value
> > > > > > > > XmlAttribute attr2 =

env.Body.OwnerDocument.CreateAttribute(WSUtility.Prefix,"Id",
> > > > > > > > WSUtility.NamespaceURI);
> > > > > > > > attr2.Value = "myIdValue";
> > > > > > > > env.Body.Attributes.Append(attr2);
> > > > > > > >
> > > > > > > > // Send response
> > > > > > > > SoapEnvelope response =

mySoapClient.GenericRequestResponse("http://stockservice.contoso.com/wse/sam
> > > > > > > > ples/2003/06/StockQuoteRequest",env);
> > > > > > > >
[quoted text clipped - 94 lines]
> > > > > > > > > > > >
> > > > > > > > > > > > The namespace changed for wsu to

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1
> > > > > > > > > .0.xsd
> > > > > > > > > > > > (not for the CanonicalizationMethod).
[quoted text clipped - 70 lines]
> > > > > > > > > > > > > >    serviceProxy.OrderTimeHeaderValue = header;
> > > > > > > > > > > > > >    SignatureReference soapRef = new

SignatureReference("#Id:05d2518d-d6db-481f-846d-2e8872b6e56d");
> > > > > > > > > > > > > >    soapRef.AddTransform(new
> > > XmlDsigExcC14NTransform());
[quoted text clipped - 58 lines]
> > > > > > > > > > in
> > > > > > > > > > > > > > message

news:ueNAc9CaEHA.3596@tk2msftngp13.phx.gbl...
> > > > > > > > > > > > > > > > > I take it that this is not possible with
> > wse...
[quoted text clipped - 47 lines]
> > > > > > > > > > > > > > > > > >
> > > > > > > > xmlns:d3p1="http://schemas.xmlsoap.org/ws/2002/07/utility"

xmlns="http://www.ros.ie/schemas/service/">Inbox/List</Operation>
> > > > > > > > > > > > > > > > > >     </soap:Header>
> > > > > > > > > > > > > > > > > >     <soap:Body wsu:Id="MsgBody"
[quoted text clipped - 9 lines]
> > > > > > > > > > > > > > > > > >     <soap:Header>
> > > > > > > > > > > > > > > > > >       <Operation Id="MsgOperation"

xmlns="http://www.ros.ie/schemas/service/">Inbox/List</Operation>"
> > > > > > > > > > > > > > > > > >     </soap:Header>
> > > > > > > > > > > > > > > > > >     <soap:Body Id="MsgBody" >
[quoted text clipped - 6 lines]
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Stewart Bourke

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.