Click here to Skip to main content
13,006,195 members (78,895 online)
Rate this:
Please Sign up or sign in to vote.
We have a WCF service, wsHttpBinding and CustomBasicAuthentication. The Client is a Windows Forms application and it works with specified username/password.

Now we need to make another client, which will be calling the service from an html page. I am trying to call the service using xmlHttpRequest but getting following error:

" message could not be processed. This is most likely because the action '' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding"

HTML page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
    <script src="Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
    function CallServer() {
        var xmlhttp = new XMLHttpRequest();'POST', 'http://localhost:56779/BeSTService.svc', true,"umais","asghar");
        xmlhttp.setRequestHeader("Content-type", "application/soap+xml");
        var sr ='<s:Envelope xmlns:a="" xmlns:s="">'+
                    '<a:Action s:mustUnderstand="1"></a:Action>'+                    
                    '</a:ReplyTo>' +                        
                    '<SayHello xmlns="">'+
<div style="margin:50px">
    <input type="button" value="Call Service"  önclick="CallServer();" />

I have also tried adding Security Header in the Soap Message:
'<o:Security s:mustUnderstand="1" xmlns:o="">' +
    '<o:UsernameToken>' +
        '<o:Username>umais</o:Username>' +
    '<o:Password>asghar</o:Password>' +
        '</o:UsernameToken>' +
'</o:Security>' +

But same error, When using IClientMessageInspector in Windows Forms Application, the SOAP Message sent is exactly same as i am using in HTML, without Security Header

Please help
Posted 10-Jan-13 20:12pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Here is the article you need
Calling WCF Services using jQuery[^]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170628.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100