tags:

views:

301

answers:

1

Hi,

I'm trying to implement an UPnP MediaServer in WCF. I'm slowly getting there, but now I've hit a brick wall. I need to add a prefix to the ServiceContract namespace. Right now I have the following:

[ServiceContract(Namespace = "urn:schemas-upnp-org:service:ContentDirectory:1")]
public interface  IContentDirectory
{
    [OperationContract(Action = "urn:schemas-upnp-org:service:ContentDirectory:1#Browse")]
    void Browse(string ObjectID, string BrowseFlag, string Filter, ulong StartingIndex, ulong RequestedCount, string SortCriteria, out string Result, out ulong NumberReturned, out ulong TotalMatches, out ulong UpdateID);
}

This listens to the correct soap-messages. However, I need the soap-body to begin with

<u:Browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">

and WCF is now listening to:

<Browse xmlns="urn:schemas-upnp-org:service:ContentDirectory:1">

How do I get the prefix there? Does it matter? Or is there another reason why the parameters are not passed into the Browse method?

UPDATE Here's some extra info: The following message is sent by a real UPnP control point. The parameters are not passed into the Browse method.

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  <s:Header>
    <To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;http://XXXXX:8731/ContentDirectory&lt;/To&gt;
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;urn:schemas-upnp-org:service:ContentDirectory:1#Browse&lt;/Action&gt;
  </s:Header>
  <s:Body>
      <u:Browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
         <ObjectID>0</ObjectID>
         <BrowseFlag>BrowseDirectChildren</BrowseFlag>
         <Filter>*</Filter>
         <StartingIndex>0</StartingIndex>
         <RequestedCount>15</RequestedCount>
         <SortCriteria />
      </u:Browse>
   </s:Body>
</s:Envelope>

This is the request that is generated by the WCF test client. Now the parameters are passed into the Browse method:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  <s:Header>
    <To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;http://XXXXXX:8731/ContentDirectory&lt;/To&gt;
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;urn:schemas-upnp-org:service:ContentDirectory:1#Browse&lt;/Action&gt;
  </s:Header>
  <s:Body>
    <Browse xmlns="urn:schemas-upnp-org:service:ContentDirectory:1">
      <ObjectID>0</ObjectID>
      <BrowseFlag>BrowseMetadata</BrowseFlag>
      <Filter>*</Filter>
      <StartingIndex>0</StartingIndex>
      <RequestedCount>0</RequestedCount>
      <SortCriteria i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" />
    </Browse>
  </s:Body>
</s:Envelope>
A: 

Why do you need a specific prefix? Are you using some software that depends on the prefix?

If that's so, then the software is broken. The two "xmlns" examples you've given are identical as far as XML is concerned. Any software that cares about the difference is badly broken and needs to learn XML.

John Saunders
I know, but that's the only difference between a soap-request that populates the parameters and a request that doesn't.Also, the UPnP specifications seem to be very explicit about that prefix.
Lodewijk