0

I want to call a web service from C#. I have added the WS by adding service reference. The WS has generated automatically the code below.

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="getIdentiteRequest", WrapperNamespace="http://serviceobject.exemple.fr", IsWrapped=true)]
public partial class getIdentiteRequest 
{
    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://serviceobject.exemple.fr", Order=0)]
    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
    public Oscar.Web.WebService.Model request;
    
    public getIdentiteRequest() 
    { }
    
    public getIdentiteRequest(MyProgram.Web.WebService.Model request) 
    {
        this.request = request;
    }
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="getIdentiteResponse", WrapperNamespace="http://serviceobject.exemple.fr", IsWrapped=true)]
public partial class getIdentiteResponse 
{
    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://serviceobject.exemple.fr", Order=0)]
    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
    public Oscar.Web.Intuiz.IdentiteResponse @return;
        
    public getIdentiteResponse() 
    {
    }
        
    public getIdentiteResponse(MyProgram.Web.WebService.IdentiteResponse @return)
    {
        this.@return = @return;
    }
}

I want now to call this web service in my program but I cannot understand how to do this. I have added below my effort to call this class:

getIdentiteRequest getIdentite = new getIdentiteRequest();
                
Model request = new Model();
request.identification = "UseId";
request.searchId = "123456789";
getIdentiteRequest.request = request;
               
getIdentiteResponse getIdentiteAltaN4R = new getIdentiteResponse();
var response = getIdentiteAltaN4R.@return;

I would be thankful if someone can indicate to me how I can call / use this web service.

Thank you in advance.

7
  • Is this code all you have that generated automatically? Commented Jul 4, 2020 at 9:18
  • the first block is generated automatically, I have not included the Model that is a classic model. Commented Jul 4, 2020 at 9:24
  • That's just the auto-generated request-response classes. Where is the auto-generated client-proxy? Maybe you need to specify a command-line switch when generating? That or revisit the options in the Add service reference window? Commented Jul 4, 2020 at 10:17
  • you only need to new the Web referenced and use it like a simple class Commented Jul 4, 2020 at 10:27
  • You will have a Type that implements the service interface and its name will end with "Client". That is what you want to use. Commented Jul 4, 2020 at 11:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.