0 Replies Latest reply on Feb 2, 2005 1:10 PM by Patrick Murphy

    Namespace URI cannot be null error

    Patrick Murphy Newbie

      I also encountered this problem yesterday. I have found a workaround.

      When you generate the Web Services stubs in Visual Studio to a document/literal service, the class fields within the generated stubs are annotated as "Unqualified". This is what is casuing the xmlns="" to be added to the fields in the XML request document. If you edit the Reference.cs stub file by hand and change the fields to "Qualified", then the generated XML request will not contain the xmlns="" and the request will be processed correctly. Be careful to only change the Request objects. If you change the Response objects as well, then .Net will not properly parse the response and your fields will not be returned correctly.

      I am including a code snippet from one of my serivces Reference.cs class for an example:


      ///
      [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://service.ais.msu.edu/types")]
      public class AddIdentity_Request
      {
      ///
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified, IsNullable=true)]
      public string appID;

      ///
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified, IsNullable=true)]
      public string clientPassword;

      ///
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified, IsNullable=true)]
      public string clientUserID;

      ///
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified, IsNullable=true)]
      public string identityToken;

      ///
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified, IsNullable=true)]
      public string ipAddress;
      }

      ///
      [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://sentinel.d6501.ais.msu.edu/types")]
      public class GetIdentity_Response {

      ///
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
      public string publicID;

      ///
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public int status;

      ///
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
      public string statusMessage;
      }