HttpClient クラスを使用して SOAP メッセージを送信しようとしています。
REST でこれを行うのは簡単に思えます (コードはhereから):
using System;
using System.Net.Http;
using System.Json;
namespace ConsoleApplication39
{
class Program
{
static void Main(string[] args)
{
HttpClient proxy = new HttpClient();
proxy.GetAsync("http://localhost:14892/api/Bloggers").ContinueWith((r) =>
{
HttpResponseMessage response = r.Result;
response.Content.ReadAsAsync<JsonArray>().ContinueWith(
(a)=>
{
foreach(var w in a.Result)
{
Console.WriteLine(w.ValueOrDefault("Name").ToString());
Console.WriteLine(w.ValueOrDefault("Intrest").ToString());
}
});
});
Console.ReadKey(true);
}
}
}
SOAPで同様のことをしたいと思います。
ホスト ( http://opensearch.addi.dk/2.2/ ) と POST への SOAP メッセージがあります。
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://oss.dbc.dk/ns/opensearch">
<SOAP-ENV:Body>
<ns1:searchRequest>
<ns1:query>dc.title=zorro AND dc.type=bog</ns1:query>
<ns1:agency>100200</ns1:agency>
<ns1:profile>test</ns1:profile>
<ns1:start>1</ns1:start>
<ns1:stepValue>10</ns1:stepValue>
</ns1:searchRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
…でもどうやって送るの?
これは私が今までに使用した最初の SOAP Web サービスであるため、何をしているのかわからないかもしれませんが、最も単純な形式では次のようになります。
HttpClient hc = new HttpClient();
hc.BaseAddress = new Uri("http://opensearch.addi.dk/2.2/");
HttpContent content = *... something*
HttpResponseMessage rm = await hc.PostAsync("http://opensearch.addi.dk/2.2/", content);
SOAP メッセージは HttpContent.Create(..) のような HttpContent 静的メソッドを介して何らかの方法で作成する必要があると想定していますが、それを機能させることはできません...
私はこれがばかげた質問であることを知っていますが、まだ助けが必要です :) !
ティア...