wsHTTPBindingとbasicHTTPBindingを介して公開されるwcfWebサービスがあります。後者は、次のように、エンドポイントアドレスを「/basic」として指定します。
<endpoint address="/basic" binding="basicHttpBinding" bindingConfiguration="theAwesomeBasicHttpServerBinding" contract="LOServices.Proxy.ServiceContracts.ILOService">
<identity>
<servicePrincipalName value="HTTP/MY_MACHINE_NAME" />
</identity>
</endpoint>
バインディングは次のように定義されます。
<basicHttpBinding>
<binding name="theAwesomeBasicHttpServerBinding" maxReceivedMessageSize="5000000">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
jqueryを使用してWebメソッドの1つを呼び出そうとしています。これはbasicHTTPBindingを超えており、RESTfulではないため、JSONは使用しません。その結果、wcfテストクライアントを介してサービスに対して行った以前の(成功した)呼び出しから要求XMLを構築しています。
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/ILOService/GetLoanActions</Action>
</s:Header>
<s:Body>
<GetLoanActions xmlns="http://tempuri.org/">
<request xmlns:d4p1="http://schemas.datacontract.org/2004/07/LOServices.Proxy.Requests" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d4p1:AssociationNumber>3</d4p1:AssociationNumber>
<d4p1:IgnoreWarnings>false</d4p1:IgnoreWarnings>
</request>
</GetLoanActions>
</s:Body>
</s:Envelope>
したがって、私が使用している実際のJavaScriptは、次のように構成されています。
function callWs() {
var theRequest = " \
<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"> \
<s:Header> \
<Action s:mustUnderstand=\"1\" xmlns=\"http://schemas.microsoft.com/ws/2005/05/addressing/none\">http://tempuri.org/ILOService/GetLoanActions</Action> \
</s:Header> \
<s:Body> \
<GetLoanActions xmlns=\"http://tempuri.org/\"> \
<request xmlns:d4p1=\"http://schemas.datacontract.org/2004/07/LOServices.Proxy.Requests\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"> \
<d4p1:AssociationNumber>3</d4p1:AssociationNumber> \
<d4p1:IgnoreWarnings>false</d4p1:IgnoreWarnings> \
</request> \
</GetLoanActions> \
</s:Body> \
</s:Envelope>";
$.ajax({
type: "POST",
url: "http://localhost/LOServices/Services/LOService.svc/basic",
data: theRequest,
timeout: 10000,
contentType: "text/xml",
dataType: "xml",
async: false
});
}
ただし、この方法で実行すると、wcfサービスから「不正な要求」を受け取ることができて残念です。それでもフォローアップの余地はあまりありません。
私は少なくとも3時間この作品を作るのに苦労してきましたので、誰かアイデアがあれば、遠慮なくいくつかの提案をしてください。
ありがとう。