2011-02-28 1 views
0

安価なwcfサービスへの標準Get Request呼び出しを作成すると、content typeが "application/xml"で返されます。ベンダーは、コンテンツタイプ「text/xml」で送信するよう求めています。これをwcfでどのように切り替えるのですか?それは属性ですか? text/xml restからの戻り呼び出し

コール

はこれです:

[ServiceContract(Namespace = "")] 
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, Namespace = "")] 
[XmlSerializerFormat(Style = OperationFormatStyle.Document, Use=OperationFormatUse.Literal)] 
public class Player 
{ 

    [WebGet(UriTemplate = "{id}")] 
    public string GetTestDetailsRequest(string id) 
    { 
     TestService.TestServiceClient testServiceClient = new TestServiceClient(); 
     string xml = testServiceClient.GetTestDetailsRequest(Guid.Parse(id)); 
     return xml; 
    } 
} 

答えて

0

あなたは、コンテンツの種類無効にすることができます:

WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";

1

しようとすると、RESTfulサービスを呼び出すためにWCFを使用しないでください。 HttpWebRequestまたはHttpClientを使用するだけで、リクエストを制御できます。

+0

のHttpClient WCF休憩スターターキットプレビューに含まれている2 http://aspnet.codeplex.com/releases/view/24644 –

+0

@JoeyのHTTPClientをサポートされなくなりました。 http://wcf.codeplex.com –

+0

に感謝の気持ちがあります。 WCFのRESTスタックが変化し続けるように思える... Glenがそれを引き継いだのを忘れてしまった。 –

関連する問題