开发者

Posting to WCF Service via HTTP

开发者 https://www.devze.com 2023-02-19 22:35 出处:网络
I\'m having trouble posting data to a WCF Service via HTTP Post an开发者_StackOverflow社区d send a redirect response back to the user.

I'm having trouble posting data to a WCF Service via HTTP Post an开发者_StackOverflow社区d send a redirect response back to the user.

My service looks like this:

[ServiceContract]
public interface IXXLeadServiceWCF
{
 [WebInvoke(UriTemplate = "invoke")]
 [OperationContract]
 void CreateCallBack(Stream input);
}

With the operation contract accepting a web invokation as follows:

[OperationBehavior]
public void CreateCallBack(Stream input)
{
 StreamReader sr = new StreamReader(input); 
 string s = sr.ReadToEnd(); 
 sr.Dispose(); 
 NameValueCollection qs = HttpUtility.ParseQueryString(s); 
 string firstName = qs["firstName"];

WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Redirect;
WebOperationContext.Current.OutgoingResponse.Location = "http://www.test.com";
}

And I'm posting to the service like this:

<form method="post" action="http://wcf.xxx.com/LeadService/LeadService.svc">
 <input name="firstName" id="firstName" class="txt_input" type="text" value="" />
</form>

I only get a blank page back from the post. Are there restrictions on HTTP posting from another domain in WCF?

If somebody could point me in the right direction, I'd really appreciate it.

Thanks

Nick


Believe your HTML form needs to be encoded multipart/form-data, yes? Also, your WebInvoke needs a method of POST, right? UriTemplate defines the URL that the method will respond to and the values it accepts as parameters.

EDIT: WebInvoke(Method="POST")

0

精彩评论

暂无评论...
验证码 换一张
取 消