2017-05-08 112 views
0

調用WCF服務的角碼之下。在當地Angular2調用WCF服務失敗

'http://localhost:34244/CitizenService.svc/register'

public customLogin(user: string, pass: string): Observable<string> { 
    let headers = new Headers({ 'Content-Type': 'application/json' }); 
    let options = new RequestOptions({ method: "POST",headers: headers,body: user}); 

    return this.http.post(this.url, user, options) 
     .map(this.extractData) 
     .catch(this.handleError); 
} 

WCF服務的URL;

它以405錯誤失敗。

enter image description here

任何人都知道可能是什麼問題?

回答

1

您在這裏遇到CORS問題。您顯示的請求實際上是一個飛行前OPTIONS請求(尚不是實際的POST請求),405 - Method not allowed表示WCF不允許使用OPTIONS方法。

也許這也有幫助:How to add cross domain support to WCF service