{
return GetRequestClientFormatter (operationDescription, endpoint);
}
-
+#if !MOBILE
public IDispatchMessageFormatter DoGetReplyDispatchFormatter (OperationDescription operationDescription, ServiceEndpoint endpoint)
{
return GetReplyDispatchFormatter (operationDescription, endpoint);
{
return GetRequestDispatchFormatter (operationDescription, endpoint);
}
-
+#endif
public event Action<ServiceEndpoint, ClientRuntime> ApplyClientBehaviorInvoked;
public override void ApplyClientBehavior (ServiceEndpoint endpoint, ClientRuntime client)
new EndpointAddress ("http://localhost:37564"));
}
+ [Test]
+ public void DefaultValues ()
+ {
+ var b = new WebHttpBehavior ();
+ Assert.AreEqual (WebMessageBodyStyle.Bare, b.DefaultBodyStyle, "#1");
+ Assert.AreEqual (WebMessageFormat.Xml, b.DefaultOutgoingRequestFormat, "#2");
+ Assert.AreEqual (WebMessageFormat.Xml, b.DefaultOutgoingResponseFormat, "#3");
+ Assert.IsFalse (b.AutomaticFormatSelectionEnabled, "#11");
+ Assert.IsFalse (b.FaultExceptionEnabled, "#12");
+ Assert.IsFalse (b.HelpEnabled, "#13");
+ }
+
[Test]
public void AddBiningParameters ()
{
Assert.AreEqual (0, pl.Count, "#1");
}
+#if !MOBILE && !MONOMAC
[Test]
public void ApplyDispatchBehavior ()
{
Assert.AreEqual (0, ed.DispatchRuntime.Operations.Count, "#4-0"); // hmm... really?
}
+#endif
[Test]
public void GetMessageFormatters ()
var b = new WebHttpBehaviorExt ();
Assert.IsNotNull (b.DoGetRequestClientFormatter (od, se), "#1");
Assert.IsNotNull (b.DoGetReplyClientFormatter (od, se), "#2");
+#if !MOBILE
Assert.IsNotNull (b.DoGetRequestDispatchFormatter (od, se), "#3");
Assert.IsNotNull (b.DoGetReplyDispatchFormatter (od, se), "#4");
+#endif
}
[Test]
}
}
+#if !MOBILE
[Test]
public void RequestClientFormatter2 ()
{
// TODO: test DeserializeReply too (it is supported unlike above).
}
+#endif
[ServiceContract]
public interface IMyService
public class MyService: IMyService
{
+#if !MOBILE
[OperationBehavior]
+#endif
public string Echo (string input)
{
return input;
Assert.IsTrue (od.Behaviors.Contains (typeof (WebGetAttribute)), "Operation is recognized as WebGet");
}
+#if !MOBILE
[Test]
public void MessageFormatterSupportsRaw ()
{
var se = new ServiceEndpoint (cd, new WebHttpBinding (), new EndpointAddress ("http://localhost:8080/"));
var wmebe = new WebMessageEncodingBindingElement ();
var wme = wmebe.CreateMessageEncoderFactory ().Encoder;
- Console.WriteLine (wme.MediaType);
var msg = wme.ReadMessage (ms, 100, null); // "application/xml" causes error.
var formatter = new WebHttpBehaviorExt ().DoGetRequestDispatchFormatter (od, se);
object [] pars = new object [1];
formatter.DeserializeRequest (msg, pars);
Assert.IsTrue (pars [0] is Stream, "ret");
}
+#endif
+ [ServiceContract]
+ public interface IMultipleParametersGet
+ {
+ [OperationContract]
+ [WebGet (UriTemplate = "get")]
+ void Get (string p1, string p2);
+ }
+
+ [ServiceContract]
+ public interface IMultipleParameters
+ {
+ [OperationContract]
+ [WebInvoke (UriTemplate = "posturi?p1={p1}&p2={p2}")]
+ string PostUri (string p1, string p2);
+
+ [OperationContract]
+ [WebInvoke (UriTemplate = "postone?p1={p1}")]
+ string PostOne (string p1, string p2);
+
+ [OperationContract]
+ [WebInvoke (UriTemplate = "postwrapped", BodyStyle=WebMessageBodyStyle.WrappedRequest)]
+ string PostWrapped (string p1, string p2);
+
+ [OperationContract]
+ [WebInvoke (UriTemplate = "out?p1={p1}&p2={p2}", BodyStyle=WebMessageBodyStyle.WrappedResponse)]
+ void PostOut (string p1, string p2, out string ret);
+ }
+
+ [Test]
+ public void MultipleParameters ()
+ {
+ var behavior = new WebHttpBehaviorExt ();
+ var cd = ContractDescription.GetContract (typeof (IMultipleParameters));
+ var se = new ServiceEndpoint (cd, new WebHttpBinding (), new EndpointAddress ("http://localhost:8080/"));
+ behavior.Validate (se);
+
+ foreach (var od in cd.Operations)
+ behavior.DoGetRequestClientFormatter (od, se);
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void MultipleParameters2 ()
+ {
+ var behavior = new WebHttpBehaviorExt ();
+ var cd = ContractDescription.GetContract (typeof (IMultipleParametersGet));
+ var se = new ServiceEndpoint (cd, new WebHttpBinding (), new EndpointAddress ("http://localhost:8080/"));
+ behavior.Validate (se);
+
+ try {
+ foreach (var od in cd.Operations)
+ behavior.DoGetRequestClientFormatter (od, se);
+ Assert.Fail ("Should result in invalid operation");
+ } catch (InvalidOperationException) {
+ }
+ }
}
[ServiceContract]