简体   繁体   中英

Calling WCF service over node proxy works on localhost only

I am trying to call a WCF Data service on another domain. The service uses NTLM, and the JSON returned depends on the authenticated user. I am using node-http-proxy to get over cross domain issues. The service, lets say

http:// otherdomain:1234 /dataservice.svc/getData

returns a JSON like

    {
        "description": "xxxxx",   
        "data": {
            "subclass": [
                [
                    {
                        "name": "xxxxx",
                        "keys": {     
                        },
                        "children": "xx"
                    }
                ]
            ]
        },
        "parameter": "someparam",
        "option": {
              "someoption": []
            }
     }

For users with no data configured, it just returns an empty JSON skeleton like

    {
        "description": "",   
        "data": {},
        "parameter": "",
        "option": {}
     }

In my proxy server I have set target as http://otherdomain:1234 and call the service as

http:// localhost:8003 /dataservice.svc/getData

from my client application. This works perfectly fine(from application and browser directly). NTLM authentication is working; no CORS issue. I am getting the JSON like the first example.

But when I call the proxy using my IP address instead, like so

http:// 10.203.147.21:8003 /dataservice.svc/getData

I get the empty JSON skeleton only, no other errors. What is happening here? Working with localhost but not IP.

Interestingly, this happens with the actual service as well; ie if I use the IP address of the data server (called directly from browser) instead of the name, I get a similar empty JSON.

http:// 10.203.147.34:1234 /dataservice.svc/getData

Could someone explain what is going on here? How to resolve this?

Setting changeOrigin to true in the options object of httpProxy has fixed the issue. Now the proxy is able to negotiate NTLM from different domain properly. Guess the server was returning empty response for requests from different origin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM