Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Hi,
there is a website that asks with ajax for some web-service web-methods. I don't have its code.
It sends POST requests and expect to get JSON as an answer.

I write this web-service. I use hataccess file with many rewrite rules.
Some rules redirect client request directly or through proxy.

Thus some stays POST requests, like the ones that pass through
RewriteCond %{HTTP_REFERER} ^http://(.*)/Bing$ [NC]
RewriteRule /ActivitiesService.asmx/GetLatest$ http://%1/ActivitiesService.asmx/GetLatestSearchActivities [NC,L,P]

And some I rewrite t a queryString form:
RewriteCond %{HTTP_REFERER} ^http://(.*)/([0-9]+) [NC]
RewriteRule /ActivitiesService.asmx/GetLatest$ http://%1/ActivitiesService.asmx/GetLatestByActivityType?activityType=%2&type=1&timestamp=10000 [NC,L,R=301]

I did so because I didn't find a way to dynamically add an additional parameter to the method.
I couldn't leave it in POST method.

The methods that are called with querySring were added
[ScriptMethod(UseHttpGet = true)]

the thing is that when I [R] redirect instead of
proxy some data is lost:

Content-Type: application/json; charset=UTF-8 turns to something with 'xml').

Even when I use Fiddler requestBuilder with this data
i get JSON as a response but with an error inside it.

I tried to call one method from another which doesn't have
ScriptMethod(UseHttpGet = true)] and is redirected by

- and everthing worked fine. Got good JSON object as expected.

Someone has an idea how can I modify my htaccess file or web-service API attributes?
<code>
[CODE]
RewriteRule ^/Bing$ http://%{HTTP:Host} [NC,L,P]
RewriteRule ^/Zynga$ http://%{HTTP:Host} [NC,L,P]
RewriteRule ^/([0-9]+)$ http://%{HTTP:Host} [NC,L,P]
RewriteRule ^/CT([0-9]+)$ http://%{HTTP:Host} [NC,L,P]

RewriteCond %{HTTP_REFERER} ^http://(.*)/Bing$ [NC]
RewriteRule /ActivitiesService.asmx/GetLatest$ http://%1/ActivitiesService.asmx/GetLatestSearchActivities [NC,L,P]

RewriteCond %{HTTP_REFERER} ^http://(.*)/Bing$ [NC]
RewriteRule /images/ConduitLive_header.png$ http://%1/images/Header_WatchItBing.png [NC,L,R=301]

RewriteCond %{HTTP_REFERER} ^http://(.*)/Zynga$ [NC]
RewriteRule /ActivitiesService.asmx/GetLatest$ http://%1/ActivitiesService.asmx/GetLatestZyngaActivities [NC,L,P]

RewriteCond %{HTTP_REFERER} ^http://(.*)/([0-9]+) [NC]
RewriteRule /ActivitiesService.asmx/GetLatest$ http://%1/ActivitiesService.asmx/GetLatestByActivityType?activityType=%2&type=1&timestamp=10000 [NC,L,R=301]

RewriteCond %{HTTP_REFERER} ^http://(.*)/CT([0-9]+) [NC]
RewriteRule /ActivitiesService.asmx/GetLatest$ http://%1/ActivitiesService.asmx/GetLatestByCtid?ctid=CT%2&type=1&timestamp=10000 [NC,L,R=301]
[/CODE]


Thanks for any help !
Have a great weekend
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900