誰かがwcfサービスにjquery soapコールを行うことができますか?jquery wcf soap call fail
私のjQueryのコード:txtTextRequestで
$.ajax({
url: "http://localhost/oseop/orderingservice.svc/HelloWorld",
data: $("#txtTestRequest").val(),
type: "POST",
processData: true,
contentType: "application/xml; charset=utf-8",
timeout: 10000,
dataType: "xml",
beforeSend: function (xhr) {
xhr.setRequestHeader("SOAPAction", "HelloWorld");
},
success: function (xml) {
console.log("Sucess");
console.log(xml);
},
error: function (xhr) {
console.log(xhr.statusText);
}
});
マイデータ:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://localhost:49720/OrderingServices/OrderingService.svc</To>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://temp.org/test/IOrder/HelloWorld</Action>
</s:Header>
<soap:Body>
<HelloWorld xmlns="http://temp.org/test/">
<name>my name is earl</name>
</HelloWorld>
</soap:Body>
</soap:Envelope>
私のC#コード:私はxhr.statusTextから次のエラーを取得する
[ServiceContract(Namespace = "http://temp.org/test/")]
public interface IOrder
{
[OperationContract]
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.Wrapped,
ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml)]
string HelloWorld(string name);
}
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
public class OrderingService : IOrder
{
public string HelloWorld(string name)
{
return String.Format("Hello {0}", name);
}
}
:
キャッチされない例外:[例外... "コンポーネントがエラーコードを返し: 0x80040111(NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.statusText" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" 場所: 「JSフレーム:: http://localhost:49758/TestClient/js/script.js ::匿名::ライン22" のデータ:なし]
ライン0
編集#1:
マイリクエストヘッダ:
OPTIONS http://localhost/oseop/orderingservice.svc/HelloWorld HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Origin: http://localhost:49758
Access-Control-Request-Method: POST
Access-Control-Request-Headers: soapaction
応答:
HTTP/1.1 400 Bad Request
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Fri, 07 Jan 2011 14:00:53 GMT
Content-Length: 0
は、サーバーで使用しているWCFバインディングとエンドポイント情報を知る必要があります。私は作業/クライアントクライアントのアプリケーションを使用して要求/応答をトレースし、そのペイロードとヘッダーをコピーすることをお勧めします。 – alexdej
ヘッダーが追加されました。それはあなたが探している場所ですか? – capdragon