.NET Framework Developer Center > .NET Development Forums > Windows Communication Foundation > Newbie Quetion calling a Service from a Client ?
Ask a questionAsk a question
 

AnswerNewbie Quetion calling a Service from a Client ?

  • Sunday, November 08, 2009 4:18 AMMachanX Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I created a WebClient

    Created a directory called ServiceReferences -> did a Add service reference and pointed it to a WCF service existing on a server -> this created a Reference.svcmap file with other wsdl / xsd/ disco/ etc files underneath it but no .cs files looks like they are moved to c:\windows\framework\...cs. (When I do add reference underneath a directory why does it create a Reference.svcmap vs creating a Namespace that I give during Add Service Reference ? - The namespace I give during Add Service reference is TestService )

    I created a basic webpage and cs file. In the cs file I am trying to access the service but don't know how.


    Now I am wondering how I do reference the service - what is the proxy Class that I can use / instantiate to call the service.

    In the Client when I say using TestService it is not able to resolve.


    The WCF service exposes mex over http and contract over namedpipe. I cannot modify the service !!!

Answers

  • Sunday, November 08, 2009 6:54 AMHaripraghash Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

    Were you able to browse the service wsdl in a web browser? I am uploading a sample which is similar to yours buti have commented the  netnamedpipe binding as i dont have IIS7. Apart from that its similar and i am not able to reproduce it.

    http://cid-05c2e50f2c5140c1.skydrive.live.com/self.aspx/.Public/ProxyGenerationtest.rar
    Please mark the response as answers if it solves your question or vote as helpful if you find it helpful. http://thoughtorientedarchitecture.blogspot.com/

All Replies

  • Sunday, November 08, 2009 4:29 AMHaripraghash Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Machi :)

    Can you post your service config and service contracts. When you do a add service reference it msut generate a reference.cs file which you will use to consume the service. By looking at the contracts and config we can try debuggig the issue
    Please mark the response as answers if it solves your question or vote as helpful if you find it helpful. http://thoughtorientedarchitecture.blogspot.com/
  • Sunday, November 08, 2009 5:21 AMMachanX Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    The following is the web.config of the service only the <System.ServieModel>

    <?xml version="1.0" encoding="utf-8" ?>
     <system.serviceModel>
            <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
            <behaviors>
                <serviceBehaviors>
                    <behavior name="myServiceBehavior">
                        <serviceMetadata httpGetEnabled="true" />
                        <serviceDebug includeExceptionDetailInFaults="true" />
                        <serviceThrottling/>
                    </behavior>
                </serviceBehaviors>
            </behaviors>
            <services>
                <service name="ServiceLogger" behaviorConfiguration="myServiceBehavior">
                    <endpoint address=""
                              binding="wsHttpBinding"
                              bindingConfiguration="myHttpBinding"
                              contract="ServiceLogger" />
                    <endpoint address="np"
                                  binding="netNamedPipeBinding"
                                  bindingConfiguration="myNamedPipeBinding"
                                  contract="ServiceLogger" />
                    <endpoint address="mex"
                              binding="mexHttpBinding"
                              contract="IMetadataExchange" />
                </service>
             </services>
    
            <bindings>
                <wsHttpBinding>
                    <binding name="myHttpBinding">
                        <security mode="None">
                            <transport clientCredentialType="None"/>
                        </security>
                    </binding>
                </wsHttpBinding>
                <netNamedPipeBinding>
                    <binding name="myNamedPipeBinding" maxConnections="100">
                        <security mode="None"></security>
                    </binding >
                </netNamedPipeBinding>
            </bindings>
        </system.serviceModel>
    
    The contents of the svc file is as follows

    <%@ ServiceHost Language="C#" Debug="true" Service="ServiceLogger, DataMart.Portal.Service" Factory="DataMart.Web.Infrastructure.Services.HostFactory" %>
    

    The contract is as follows
    [ServiceContract(Namespace = "DataMart.Portal.Services")]
    [ServiceBehavior(Namespace = "DataMart.Portal.Services")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class ServiceLogger : MyBaseService
    {
    
        [OperationContract] public IList<RecordResult> ListRowResult(int RowID, int rowLimit)
        {
            return ServiceLogger.ListRecordsForRowID(RowID, rowLimit).ToRecordResult();
            
        }
    
        [OperationContract] public void Log(RecordParameter record)
        {
            ServiceLogger.Log(record.ToRecord(RecordTypeFactory, CustomerRepository));
        }
    }
    

  • Sunday, November 08, 2009 6:54 AMHaripraghash Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

    Were you able to browse the service wsdl in a web browser? I am uploading a sample which is similar to yours buti have commented the  netnamedpipe binding as i dont have IIS7. Apart from that its similar and i am not able to reproduce it.

    http://cid-05c2e50f2c5140c1.skydrive.live.com/self.aspx/.Public/ProxyGenerationtest.rar
    Please mark the response as answers if it solves your question or vote as helpful if you find it helpful. http://thoughtorientedarchitecture.blogspot.com/