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

  • SEARCH
  • Home
  • 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 612587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:54:35+00:00 2026-05-13T17:54:35+00:00

I am interested in impersonating well-known Web Services and Wcf Services for integration test

  • 0

I am interested in impersonating well-known Web Services and Wcf Services for integration test purposes. To this end, I would like to capture service metadata, auto-generate service stubs, and host service stubs in a self-hosted environment.

Following this article here, I am able to obtain remote Wcf Service metadata and generate contracts. However, I am having some difficulty doing the same for remote Asmx Web Services.

I have a set of mickey-mouse solutions for vetting this out.

My Asmx solution contains a default “Hello World” web service, found below

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class SimpleAsmxService : System.Web.Services.WebService
{
    [WebMethod]
    public string HelloWorld () { return "Hello World"; }
}

My Wcf solution contains a default “Hello World” service, also found below

[ServiceContract]
public interface ISimpleWcfService
{
    [OperationContract]
    string GetData(int value);

    [OperationContract]
    CompositeType GetDataUsingDataContract(CompositeType composite);
}

[DataContract]
public class CompositeType
{
    [DataMember]
    public bool BoolValue { get; set; }

    [DataMember]
    public string StringValue { get; set; }
}

public class SimpleWcfService : ISimpleWcfService
{
    public string GetData(int value)
    {
        return string.Format("You entered: {0}", value);
    }

    public CompositeType GetDataUsingDataContract(CompositeType composite)
    {
        if (composite.BoolValue)
        {
            composite.StringValue += "Suffix";
        }
        return composite;
    }
}

Finally, the little console-that-could looks like

class Program
{
    public const string UrlWcf = 
        "http://localhost:8731/Design_Time_Addresses/SimpleWcfService/mex";
    public const string UrlAsmx = 
        "http://localhost:1803/SimpleAsmxService.asmx?WSDL";

    static void Main(string[] args)
    {
        EndpointAddress mexAddress = new EndpointAddress (UrlWcf);
        MetadataExchangeClient mexClient = 
            new MetadataExchangeClient (mexAddress);
        mexClient.ResolveMetadataReferences = true;

        // NOTE: blows up if we use UrlAsmx
        MetadataSet metaSet = mexClient.GetMetadata ();

        WsdlImporter importer = new WsdlImporter (metaSet);
        Collection<ContractDescription> contracts = 
            importer.ImportAllContracts();
    }
}

It seems to me that I should be able to pull Wsdl from a well-known Asmx Web Service and generate contracts [and from contracts to code], but cannot seem to contort the preceding sample to do so. Any help would be much appreciated,

Thanks!


NOTE: the error generated when invoking MetadataSet metaSet = mexClient.GetMetadata(); above is a System.InvalidOperationException with message of

Metadata contains a reference that cannot be resolved : ‘http://localhost:1803/SimpleAsmxService.asmx?WSDL‘

With a System.InvalidOperationException inner exception with message of

<?xml version="1.0" encoding="utf-16"?>
<Fault xmlns="http://www.w3.org/2003/05/soap-envelope">
    <Code>
        <Value>Sender</Value>
    </Code>
    <Reason>
        <Text xml:lang="en">
System.Web.Services.Protocols.SoapException: Unable to handle request without a valid action parameter. Please supply a valid soap action.
   at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest()
   at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
   at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean&amp; abortProcessing)
        </Text>
    </Reason>
</Fault>
  • 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-13T17:54:36+00:00Added an answer on May 13, 2026 at 5:54 pm

    The way to get it to work with an ASMX web service is to specify the MetadataExchangeClientMode

    ...
    MetadataExchangeClient mexClient = 
        new MetadataExchangeClient (new Uri(), MetadataExchangeClientMode.HttpGet);
    ...
    

    using MetadataExchangeClientMode.HttpGet for your ASMX services
    and MetadataExchangeClientMode.MetadataExchange for your WCF services.

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

Sidebar

Related Questions

Not interested in any source control OR shell integration. This is basically to make
I would be interested in something like a multi index container in shared memory.
Interested in: 1) Is it possible to do this in a unix like OS?
I'm interested in modifying some protected values in this object. More specifically, I'd like
I am interested in doing this C code in Java: // sets n's ith
I´m interested in both web resources and books. It´s a jungle out there, please
Most interested in peer-to-peer solutions - without central server. So, I imagine it like
Interested in people's opinion. You have an application server running 3/4 services that do
im interested to implement something but im not sure if it would be possible
I'm interested in a protecting of my web application by using generation a csrf

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.