none
strange <Specified> fields in web-service using VS 2013 RRS feed

  • Question

  • I am working on a web-service application that calls external web-services run by a company in Norway.

    If I open the wsdl files in notepad, I can see the fields I want to send.

    If I look at the web-service in VS 2013, I can see the fields, plus some extra Boolean fields called *fieldname*Specified ... these extra fields are not known to the web-service provider bods in Norway.

    To clarify, say I want to send a value called `ActivateFlag` I can set that in the SoapBody using code like this:

    wsSoapBody.ActivateFlag = Convert.ToInt32(aMessage[(int)cardActivate.ActivateFlag].ToString()); // 0 for activate    

    Now I am logging my Soap Requests to external files (via SoapExtensions), and if I do the above, I should see a field like this in the SoapRequest XML:

    <ActivateFlag xmlns="">0</ActivateFlag>

    but it's not there **unless** I also set the field `ActivateFlagSpecified=true` like this:

    wsSoapBody.ActivateFlagSpecified = true;

    then I can see it and the value is updated correctly on the destination system at the other end.

    Question:
    Where is this field coming from - have I done something in VS 2013 that means I need to specify that a field is specified if I want it output in the SoapBody of the service call?

    The providers of the web-service have no knowledge of these fields, and when I look at the web-service in the VS Object Browser, the fields are there, but if I look at the wsdl file, they aren't.

    Friday, February 6, 2015 9:39 AM

All replies

  • Hi,

    You may refer to the following links for more information:

    http://stackoverflow.com/questions/8230772/server-error-in-wcf

    http://weblog.west-wind.com/posts/2007/Dec/09/Tracing-WCF-Messages

    This is absolutely useless information which is a waste of time, but thanks anyway for posting useless links.

    this is answering a different question, my question is about Specified fields being required when they are not in the wsdl...

    Thursday, February 12, 2015 2:23 PM
  • Hi,

    For this situation, it seems that the ActivateFlagSpecified is provided by the web-services company. And you could check it within the Visual studio object browser after you add the service reference.

    However, you could not check it within the wsdl file, so it's recommended that you could ask the service provider to check whether it's a service related property.

    Regards

    Friday, February 13, 2015 5:46 AM
    Moderator
  • Hi,

    For this situation, it seems that the ActivateFlagSpecified is provided by the web-services company. And you could check it within the Visual studio object browser after you add the service reference.

    However, you could not check it within the wsdl file, so it's recommended that you could ask the service provider to check whether it's a service related property.

    Regards

    Hi,

    Thanks for your answer, but no, the web-service provider have no knowledge of these fields - it seems to be added by the web-service toolkit in Visual Studio .NET...

    In the WSDL file that I can look at in Internet explorer, notepad, or Notepad++ - they are not there.

    But in Visual Studio, in the Object Browser they are there, and when I double click on a field the tool generates Reference.cs that includes them, defined as below:

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public long CardId {
        get {
            return this.cardIdField;
        }
        set {
            this.cardIdField = value;
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public bool CardIdSpecified {
        get {
            return this.cardIdFieldSpecified;
        }
        set {
            this.cardIdFieldSpecified = value;
        }
    }
    

    and the only difference between these fields and the normal fields is this:

    [System.Xml.Serialization.XmlIgnoreAttribute()]
    so what is going on?

    Philip


    Friday, February 13, 2015 12:25 PM