0

更新するページのURL(クリックしてもリンクは機能しません。サンプルです):https ://test-services.zzz111.org/yyy-9/center/api/rest/v1/pols/ZYPK

このURLでPOSTを実行する必要があると想定しています。

リクエストのサンプルは次のとおりです。

<PolChangeSet schemaVersion="2.1" username="ZZ@yyy999.com" description="Adding a note">
    <Attachment name="pic.jpg" contentType="image/jpeg">
        <Description/>
        <Location>https://services.zzz111.com/yyy-9/center/api/sdo/rest/v1/buckets/attachments/objects/6BD0C43B-4608-0EDE-F6DA-919097EFCABF.jpg</Location>
    </Attachment>
</PolChangeSet>

このHTTPPOSTリクエストをURLに送信するにはどうすればよいですか?

4

2 に答える 2

1

バックエンドに投稿する必要がある場合は、このhttp://www.hanselman.com/blog/HTTPPOSTsAndHTTPGETsWithWebClientAndCAndFakingAPostBack.aspxを参照できます。

そして、XMLを介してURIとパラメーターを文字列として渡します

元のソースを編集し、追加のパラメーターとしてcontentTypeを追加しました。XMLタイプは"application/xml"

public static string HttpPost(string URI, string Parameters, string contentType) 
{
   System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
   req.Proxy = new System.Net.WebProxy(ProxyString, true);
   //Add these, as we're doing a POST
   req.ContentType = contentType;
   req.Method = "POST";
   //We need to count how many bytes we're sending. Post'ed Faked Forms should be name=value&
   byte [] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
   req.ContentLength = bytes.Length;
   System.IO.Stream os = req.GetRequestStream ();
   os.Write (bytes, 0, bytes.Length); //Push it out there
   os.Close ();
   System.Net.WebResponse resp = req.GetResponse();
   if (resp== null) return null;
   System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
   return sr.ReadToEnd().Trim();
}
于 2012-08-10T01:20:11.840 に答える
0

これを行うにはjqueryを使用できます。

$.post(
    "action.php", 
    {"xmlString":xmlString}, 
    function (response){
        alert(response);
    }
);

次に、サーバー側でオブジェクトのxml文字列を解析できます。jqueryposthttp://api.jquery.com/jQuery.post/に関するいくつかの例を次に示します

または、この答えを見ることができます。これは似ています。POSTメソッドとjqueryajaxを使用してxmlをパラメーターとして渡す方法

于 2012-08-10T00:54:03.327 に答える