Loading ...
Sorry, an error occurred while loading the content.

Re: [soapbuilders] Soap Envelope namespace

Expand Messages
  • Tomas Bahnik
    Have you read related MSDN articles eg. [1] and in particular [2]? Tomas [1]
    Message 1 of 2 , Sep 29, 2005
    • 0 Attachment
      Have you read related MSDN articles eg. [1] and in particular [2]?

      Tomas

      [1]
      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconSerialization.asp
      [2]
      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconattributesthatcontrolserialization.asp

      ----- Original Message -----
      From: "psipjay" <jtreptow@...>
      To: <soapbuilders@yahoogroups.com>
      Sent: Wednesday, September 28, 2005 7:30 PM
      Subject: [soapbuilders] Soap Envelope namespace


      Hi,
      I have a C# Web Service proxy class that was generated from a WSDL
      file using the wsdl.exe program. I am trying to get the code to
      insert an additional namespace into the soap envelope when a message
      is sent from my program. No matter what I try the namespace does
      not get added.

      As an example I put together a service that sends an integer message.
      The outgoing soap message looks like the following.
      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope
      xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
      <OutMsg xmlns="http://schemas.example.org/MyService">
      <Val>777</Val>
      </OutMsg>
      </soap:Body>
      </soap:Envelope>

      I want to add a namespace to the Soap:Envelope so that it is the
      following:

      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope
      xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:mys="http://schemas.example.org/MyService" >
      <soap:Body>
      <OutMsg">
      <Val>777</Val>
      </OutMsg>
      </soap:Body>
      </soap:Envelope>

      The generated class code looks like this:

      [System.CodeDom.Compiler.GeneratedCodeAttribute
      ("wsdl", "2.0.50727.26")]
      [System.Diagnostics.DebuggerStepThroughAttribute()]
      [System.ComponentModel.DesignerCategoryAttribute("code")]
      [System.Web.Services.WebServiceBindingAttribute
      (Name="SimpleServiceSoap12Binding",
      Namespace="http://schemas.example.org/MyService")]
      public partial class MyService :
      System.Web.Services.Protocols.SoapHttpClientProtocol
      {

      private System.Threading.SendOrPostCallback
      OutMsgOperationCompleted;

      /// <remarks/>
      public MyService() {
      this.SoapVersion =
      System.Web.Services.Protocols.SoapProtocolVersion.Soap12;
      this.Url = "http://serverURL/MyService";
      }
      /// <remarks/>
      public event OutMsgCompletedEventHandler OutMsgCompleted;

      //***** code I added to add additional namespaces *****
      [XmlNamespaceDeclarations]
      public XmlSerializerNamespaces soapEnvNs;

      /// <remarks/>
      [System.Web.Services.Protocols.SoapDocumentMethodAttribute
      ("http://schemas.example.org/MyService/OutMsg",
      RequestNamespace="http://schemas.example.org/MyService",
      OneWay=true,
      Use=System.Web.Services.Description.SoapBindingUse.Literal,
      ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapp
      ed)]
      public void OutMsg(int Val,

      [System.Xml.Serialization.XmlAnyElementAttribute()]
      System.Xml.XmlElement[] Any,

      [System.Xml.Serialization.XmlAnyAttributeAttribute()]
      System.Xml.XmlAttribute[] AnyAttr)
      {
      this.Invoke("OutMsg", new object[] {
      Param,
      Any,
      AnyAttr});
      }
      . the rest removed

      }

      In the calling code I am doing the following to set the namespace:

      MyService myService = new MyService();
      myService.soapEnvNs = new XmlSerializerNamespaces();
      myService.soapEnvNs.Add
      ("mys", "http://schemas.example.org/MyService");
      myService.OutMsg(777, null, null);

      The code all compiles fine but the namespace just doesn't get added.

      Has anybody done this before that could help me figure out why this
      is not working?

      Jay






      -----------------------------------------------------------------
      This group is a forum for builders of SOAP implementations to discuss
      implementation and interoperability issues. Please stay on-topic.
      Yahoo! Groups Links
    Your message has been successfully submitted and would be delivered to recipients shortly.