だから私はこの時点で立ち往生しています。JanRainの「auth_info」サービスと通信しようとしています。実際、最初に、ブラウザで直接サーフィンしたときに表示される「エラー」メッセージ/オブジェクト/「。jsthingy」を取得しようとしています。
https://rpxnow.com/api/v2/auth_info
しかし、WCF呼び出しでそれを取り戻したいと思います。
Fiddlerによると、そのURLの情報のコンテンツタイプはtext/javascriptです。しかし、私が言えることから、WCFは、WCFを介して呼び出すときにそのオプションを提供しません。WebMessageFormat.Json
、、またはの2つのオプションがあります WebMessageFormat.Xml
。
VisualStudioで次のエラーが発生します。
InvalidOperationExceptionはユーザーコードによって処理されませんでした-着信メッセージのメッセージ形式が予期しない「Raw」です。操作に必要なメッセージ形式は「Xml」、「Json」です。これは、WebContentTypeMapperがバインディングで構成されていないことが原因である可能性があります。詳細については、WebContentTypeMapperのドキュメントを参照してください。
WTF?それで、WCFはこれを行うことさえできますか?(私は先にもっと手動の解決策を疑っています)
JanRainのオンラインコード例は、C#の例には少し欠けています。
auth_infoのドキュメントリンクはこちら https://rpxnow.com/docs#auth_info
彼らのauth_infoサービスのアドレスはここにあります:
https://rpxnow.com/api/v2/auth_info
[TestMethod]
public void CallJanRain()
{
var x = new JanRainProxy("https://rpxnow.com/api/v2");
x.GetAuthInfo("", ""); //the params are apiKey, and token. not passing either at the moment as I want to be able to know how to at least handle the error first. After all, the *browser* at least got it..
}
[ServiceContract]
public interface IJanRainContract
{
[OperationContract(Name="auth_info")]
[WebInvoke(BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Xml)]
JanRainAuthInfo GetAuthInfo(string apiKey, string token);
}
[DataContract]
public class JanRainAuthInfo
{
[DataMember(Name="identifier")]
public string Identifier { get; set; }
}
public class JanRainProxy: ClientBase<IJanRainContract>
{
public JanRainProxy(string url, WebHttpSecurityMode securityMode = WebHttpSecurityMode.Transport)
: base(ConstructEndpoint(url, securityMode))
{
}
//JanRainContract
public JanRainAuthInfo GetAuthInfo(string apiKey, string token)
{
return base.Channel.GetAuthInfo(apiKey, token);
}
// This method constructs a WebHttpBinding endpoint with all the appropriate
// settings for talking to our services.
private static ServiceEndpoint ConstructEndpoint(string serviceUri, WebHttpSecurityMode securityMode)
{
var contract = ContractDescription.GetContract(typeof(IJanRainContract));
var binding = new WebHttpBinding(securityMode);
//{
// MaxBufferPoolSize = 524288000,
// MaxReceivedMessageSize = 65536000
//};
var address = new EndpointAddress(serviceUri);
var endpoint = new ServiceEndpoint(
contract,
binding,
address);
var webHttpBehavior = new WebHttpBehavior()
{
DefaultBodyStyle = WebMessageBodyStyle.Wrapped,
DefaultOutgoingRequestFormat = WebMessageFormat.Json,
DefaultOutgoingResponseFormat = WebMessageFormat.Json,
AutomaticFormatSelectionEnabled = true,
FaultExceptionEnabled = true
};
endpoint.Behaviors.Add(webHttpBehavior);
return endpoint;
}
}
おそらく、コンテンツタイプをjsonのままにして、動作またはバインディングを微調整する必要があると考えています。