locked
Service Reference from a Service RRS feed

  • Question

  • Very odd. I created a service and added a service reference to the Service.  In references.cs in one service it looked like this

    namespace SFRService.cabinsystem {
        using System.Data;
        
        
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
        [System.ServiceModel.ServiceContractAttribute(Namespace="http://cabinsys.xxxyy.com/", ConfigurationName="cabinsystem.CabinUtilityServiceSoap")]
        public interface CabinUtilityServiceSoap {
            
            [System.ServiceModel.OperationContractAttribute(Action="http://xxxyyy.com/HelloWorld", ReplyAction="*")]
            [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
            string HelloWorld();
           

    We went to create another service  and found when we referenced it...  all parts the same but when it came to the function

    ATEService.cabinservice.HelloWorldResponse HelloWorld(ATEService.cabinservice.HelloWorldRequest request);

    Whereas we could compile the first, the 2nd does not

    Severity    Code    Description    Project    File    Line    Suppression State
    Error    CS0426    The type name 'cabinservice' does not exist in the type 'ATEService'    ATEService    C:\Users\abcd\Source\Workspaces\EOT BTE ATESYS\Projects\Web\Services\ATEService\ATEService\Service References\cabinservice\Reference.cs    21    Active

    How do we generate a simple reference like the first... in that code we simply did this:

    cabinsystem.CabinUtilityServiceSoapClient sc = new cabinsystem.CabinUtilityServiceSoapClient();

    sc.HelloWorld();

    How did this generated code ATEService.cabinservice.HelloWorldResponse sneak in and how to get something simple back ?

    Thanks AndrewCw


    andrew

    Thursday, November 3, 2016 5:13 AM

Answers

  • OK have found some help on line - here's what needs to be done.

    First

    Class Name & Namespace must be different !

    namespace ATEService

    {

        // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.

        // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.

        public class ATESvc : IATESvc

     

    Next when you add the reference go to advanced & select internal, not public


    andrew

    • Marked as answer by andrewcw Thursday, November 3, 2016 4:05 PM
    Thursday, November 3, 2016 4:04 PM

All replies

  • Ah part of the problem is I had selected public on the advanced tab for setting the service reference.... doing internal seems to at least resolve the first oddness.

    andrew

    Thursday, November 3, 2016 5:32 AM
  • Hi Andrew,

    It seems you have resolved your issue by changing public to internal, if so, I would suggest you mark your reply as answer, and then other community members would find the solution easily.

    If not, it would be helpful if you could share us detailed steps that you create the second service and how you added the reference, and then we could try to reproduce your issue.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 3, 2016 9:03 AM
  • I have 2 solution ( WCF services ) - both references.cs appear identical - creating partial class, types, and functions. 

    The difference is that in the 2nd solution ( new  WCF service )   we cannot compile.  The red squiggly is under cabinsystem , with the error  The type name 'cabinsytem' does not exist in 'ATEService.   What could lead to the 2 different outcomes and what could we have missed  ?  ( cabinsystem is the namespace used when adding the service to our service ). 

    example

     internal partial class CabinUtilityServiceSoapClient : System.ServiceModel.ClientBase<ATEService.cabinsystem.CabinUtilityServiceSoap>, ATEService.cabinsystem.CabinUtilityServiceSoap {
            
            public CabinUtilityServiceSoapClient() {



    andrew



    • Edited by andrewcw Thursday, November 3, 2016 3:44 PM
    Thursday, November 3, 2016 3:19 PM
  • OK have found some help on line - here's what needs to be done.

    First

    Class Name & Namespace must be different !

    namespace ATEService

    {

        // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.

        // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.

        public class ATESvc : IATESvc

     

    Next when you add the reference go to advanced & select internal, not public


    andrew

    • Marked as answer by andrewcw Thursday, November 3, 2016 4:05 PM
    Thursday, November 3, 2016 4:04 PM