WCF を使用してポスト経由で xml データを送信するにはどうすればよいですか?
たとえば、私はいくつかのコードを持っています:
public interface IServiceForILobby
{
[OperationContract]
[WebInvoke(Method = "POST")]
string SendXml(string response);
}
//これはホストです
static void Main(string[] args)
{
Console.WriteLine("*Console Based Rest HOST*");
using (WebServiceHost serviceHost = new WebServiceHost(typeof(ServiceForILobby)))
{
serviceHost.Open();
Console.ReadLine();
}
/*これはクライアントです*/
using (ChannelFactory<IServiceForILobby> cf = new ChannelFactory<IServiceForILobby>(new WebHttpBinding(), "http://192.168.1.103:50000/RestService/SendXml?response={x}"))
{
cf.Endpoint.EndpointBehaviors.Add(new WebHttpBehavior());
IServiceForILobby channel = cf.CreateChannel();
string s;
// s = channel.SendXml("http://192.168.1.103:50000/RestService/SendXml?response={x}");
string a;
using (StreamReader sr = new StreamReader("simplexml.txt"))
{
string xmlCode = sr.ReadToEnd();
s = channel.SendXml(xmlCode);
}
クライアントからホストに XML を送信し、このように解析した後、XML ファイルを解析するにはどうすればよいですか?