私のGETエンドポイントはすべてチャンピオンのように機能しますが、私はwebinvokeメソッド= "POST"を実装しようとしています。WCF Webからの不正要求が発生しました
私のフォーマットには何か問題があると思いますが、それが何であるかは分かりません。
[ServiceContract]
interface iFlowRate
{
[OperationContract]
[WebInvoke(Method="POST",UriTemplate = "Add?apikey={apikey}",RequestFormat= WebMessageFormat.Xml)]
string AddFlowRate(string apikey,FlowRate flowrate);
}
これをデバッグすると、この方法にもなりません。 私はこのようなサービスを呼び出しています。
string postData = "<FlowRate ><wellname>wellname</wellname></FlowRate>";
//Setup the http request.
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "POST";
request.ContentLength = postData.Length;
request.ContentType = "application/xml";
request.KeepAlive = true;
StreamWriter streamwriter = new
StreamWriter(request.GetRequestStream());
streamwriter.Write(postData);
streamwriter.Close();
// Get the response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// Read the response
StreamReader responsereader = new StreamReader(response.GetResponseStream());
string strResponseData = responsereader.ReadToEnd();
BTWは、WCF 4.0を使用して、どんな助けも大歓迎です。
POSTを実行しようとしているURLは何ですか? –
また、FlowRateクラスはどのように定義されていますか? – carlosfigueira
url = localhost:4369/FlowRate/Add?apikey = 32q13e4-c78a-ce9d-e011-15eacd8e8958 "; {[DataContract] public class FlowRate {[DataMember]パブリック文字列ウェルネーム{get; set;}}} – Matt