Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6039697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:24:26+00:00 2026-05-23T06:24:26+00:00

I have a web service created using Apache CXF, and two .NET clients using

  • 0

I have a web service created using Apache CXF, and two .NET clients using Web References (not Service References). The compact framework client works, but the .NET 4.0 desktop client only works when talking to localhost. Here’s the client setup:

        var client = new Permission.Permission();
        client.Credentials = new NetworkCredential(username, password);
        client.PreAuthenticate = true;
        client.Url = url + "/Permission";

If url is http://localhost:8080/ the call succeeds, but if it is http://127.0.0.1:8080 the call fails with an error 401. For some reason the generated client code stops at the 401 response, and does not send the username and password.

Edit: I’ve found the culprit, but I don’t know the final answer. Visual Studio has inserted this section into the app.config file:

<applicationSettings>
    <MyService.Properties.Settings>
        <setting name="MyService_Permission_Permission" serializeAs="String">
            <value>http://localhost:8080/api/Permission</value>
        </setting>
    </MyService.Properties.Settings>
</applicationSettings>

The authentication works if I change the app.config to match the required URL. So my key question is: how does my code command the generated client to switch to a different instance of the web service, without editing app.config and restarting?

For further background, when I move the service code to another machine Wireshark shows the following sequence:

  1. Service to client:

     HTTP/1.1 100 Continue\r\n
    
  2. Client to Service:

     POST /api/Permission HTTP/1.1
     User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.225)
     VsDebuggerCausalityData: uIDPo8B4pxEyITVOlb6i18R2juMAAAAACwClY0YyykuVhoiZKG7oEPZ1kukkB6NLnxx6RVnHjT8ACQAA
     Content-Type: text/xml; charset=utf-8
     SOAPAction: ""
     Host: xxxxxx:8080
     Content-Length: 307
     Expect: 100-continue
    
  3. Service to Client:

     HTTP/1.1 401 Unauthorized
     Content-Length: 0
     content-type: text/xml; charset=utf-8
     Expect: 100-continue
     Host: xxx:8080
     SOAPAction: ""
     User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.225)
     VsDebuggerCausalityData: uIDPo8B4pxEyITVOlb6i18R2juMAAAAACwClY0YyykuVhoiZKG7oEPZ1kukkB6NLnxx6RVnHjT8ACQAA
     WWW-Authenticate: Basic realm=realm
     Server: Jetty(6.1.25)
    
  4. At the point the client should repeat the POST with basic authentication header added, but instead it stops.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:24:27+00:00Added an answer on May 23, 2026 at 6:24 am

    I’ve tracked down the answer. The hostname localhost is magic in a Web Reference. Inside the generated code lives this function:

        private bool IsLocalFileSystemWebService(string url) {
            if (((url == null) 
                        || (url == string.Empty))) {
                return false;
            }
            System.Uri wsUri = new System.Uri(url);
            if (((wsUri.Port >= 1024) 
                        && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
                return true;
            }
            return false;
        }
    }
    

    By changing my app.config to default to 127.0.0.1, I bypass the special behaviour for authentication of local web services.

    The moral of this story: don’t use localhost in the URL when developing a web reference client against a local instance of the service.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two webapps: a web-service client and a server (both CXF-based, using the
We have to create a web service client using Apache CXF in Java. The
I have created a web service which has a couple of methods developed using
I have a web service, created using C#. For some reason, it seems to
i have created a simple web service using Php Nusoap. its working correctly but
I have created iPad application which downloads images using web service. But my application
I'm not familiar with the web services. I created a Email Service using web
I have a web service that I created in C# and a test harness
I have a web service I'm trying to load test. I created a program
I have created an web service I need to publish this service. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.