Skip to content

Commit

Permalink
[WCF]: Support embedded <wsp:Policy> elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Baulig committed Dec 5, 2012
1 parent 99978bb commit c76c29c
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 3 deletions.
Expand Up @@ -237,6 +237,10 @@ void ImportPolicy (WSBinding binding, ServiceEndpoint endpoint)
continue;
if (!xml.NamespaceURI.Equals (Constants.WspNamespace))
continue;
if (xml.LocalName.Equals ("Policy")) {
context.AddPolicyAssertion (xml);
continue;
}
if (!xml.LocalName.Equals ("PolicyReference"))
continue;
var uri = xml.GetAttribute ("URI");
Expand Down
Expand Up @@ -269,7 +269,7 @@ static void CheckEndpoint (ServiceEndpoint endpoint, string uri, TestLabel label
Assert.That (xml, Is.Not.Null, label.Get ());

Assert.That (xml.NamespaceURI, Is.EqualTo (WspNamespace), label.Get ());
Assert.That (xml.LocalName, Is.EqualTo ("PolicyReference"), label.Get ());
Assert.That (xml.LocalName, Is.EqualTo ("PolicyReference") | Is.EqualTo ("Policy"), label.Get ());
}
label.LeaveScope ();

Expand Down Expand Up @@ -351,7 +351,7 @@ static void CheckEndpoint (ServiceEndpoint endpoint, string uri, TestLabel label
label.EnterScope ("policy-xml");
Assert.That (xml, Is.Not.Null, label.Get ());
Assert.That (xml.NamespaceURI, Is.EqualTo (WspNamespace), label.Get ());
Assert.That (xml.LocalName, Is.EqualTo ("PolicyReference"), label.Get ());
Assert.That (xml.LocalName, Is.EqualTo ("PolicyReference") | Is.EqualTo ("Policy"), label.Get ());
label.LeaveScope ();
}

Expand Down Expand Up @@ -549,7 +549,7 @@ static void CheckEndpoint (ServiceEndpoint endpoint, string uri, TestLabel label
Assert.That (xml, Is.Not.Null, label.Get ());

Assert.That (xml.NamespaceURI, Is.EqualTo (WspNamespace), label.Get ());
Assert.That (xml.LocalName, Is.EqualTo ("PolicyReference"), label.Get ());
Assert.That (xml.LocalName, Is.EqualTo ("PolicyReference") | Is.EqualTo ("Policy"), label.Get ());
label.LeaveScope ();
}

Expand Down
Expand Up @@ -25,7 +25,16 @@
// THE SOFTWARE.

using System;
using System.Net;
using System.Xml;
using System.Text;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using NUnit.Framework;
using NUnit.Framework.Constraints;
using NUnit.Framework.SyntaxHelpers;

namespace MonoTests.System.ServiceModel.MetadataTests {

Expand All @@ -40,5 +49,14 @@ public class ImportTests_LoadMetadata : ImportTests {
get { return TestContext.LoadMetadataContext; }
}

[Test]
public virtual void BasicHttp_Mtom_EmbeddedPolicy ()
{
TestLabel label;
var doc = GetMetadata ("BasicHttp_Mtom_EmbeddedPolicy", out label);

BindingTestAssertions.BasicHttpBinding (
Context, doc, WSMessageEncoding.Mtom, label);
}
}
}
Expand Up @@ -75,5 +75,6 @@
<EmbeddedResource Include="Resources\NetTcp_TransportSecurity.xml" />
<EmbeddedResource Include="Resources\NetTcp_TransportWithMessageCredential.xml" />
<EmbeddedResource Include="Resources\http-error.xml" />
<EmbeddedResource Include="Resources\BasicHttp_Mtom_EmbeddedPolicy.xml" />
</ItemGroup>
</Project>
@@ -0,0 +1,68 @@
<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
<MetadataSection Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="service" targetNamespace="http://tempuri.org/" xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xs:schema xmlns:tns="http://tempuri.org/Imports" targetNamespace="http://tempuri.org/Imports" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
</xs:schema>
</types>
<portType name="MyContract" />
<binding name="BasicHttpBinding_MyContract" type="tns:MyContract">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsp:Policy wsu:Id="BasicHttpBinding_MyContract_policy">
<wsp:ExactlyOne>
<wsp:All>
<wsoma:OptimizedMimeSerialization xmlns:wsoma="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" />
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</binding>
<service name="service">
<port name="BasicHttpBinding_MyContract" binding="tns:BasicHttpBinding_MyContract">
<soap:address location="http://tempuri.org/TestHttp/" />
</port>
</service>
</definitions>
</MetadataSection>
<MetadataSection Dialect="http://www.w3.org/2001/XMLSchema" Identifier="http://schemas.microsoft.com/2003/10/Serialization/">
<xs:schema xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="anyType" nillable="true" type="xs:anyType" />
<xs:element name="anyURI" nillable="true" type="xs:anyURI" />
<xs:element name="base64Binary" nillable="true" type="xs:base64Binary" />
<xs:element name="boolean" nillable="true" type="xs:boolean" />
<xs:element name="byte" nillable="true" type="xs:byte" />
<xs:element name="dateTime" nillable="true" type="xs:dateTime" />
<xs:element name="decimal" nillable="true" type="xs:decimal" />
<xs:element name="double" nillable="true" type="xs:double" />
<xs:element name="float" nillable="true" type="xs:float" />
<xs:element name="int" nillable="true" type="xs:int" />
<xs:element name="long" nillable="true" type="xs:long" />
<xs:element name="QName" nillable="true" type="xs:QName" />
<xs:element name="short" nillable="true" type="xs:short" />
<xs:element name="string" nillable="true" type="xs:string" />
<xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte" />
<xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt" />
<xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong" />
<xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort" />
<xs:element name="char" nillable="true" type="tns:char" />
<xs:simpleType name="char">
<xs:restriction base="xs:int" />
</xs:simpleType>
<xs:element name="duration" nillable="true" type="tns:duration" />
<xs:simpleType name="duration">
<xs:restriction base="xs:duration">
<xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?" />
<xs:minInclusive value="-P10675199DT2H48M5.4775808S" />
<xs:maxInclusive value="P10675199DT2H48M5.4775807S" />
</xs:restriction>
</xs:simpleType>
<xs:element name="guid" nillable="true" type="tns:guid" />
<xs:simpleType name="guid">
<xs:restriction base="xs:string">
<xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}" />
</xs:restriction>
</xs:simpleType>
<xs:attribute name="FactoryType" type="xs:QName" />
</xs:schema>
</MetadataSection>
</Metadata>

0 comments on commit c76c29c

Please sign in to comment.