I'm trying to figure out how to allow my SOAP headers to have a different
namespace than the web service itself.

I've got a standard web service and SOAP header defined:

[WebService(Namespace="http://epicor.com/apps/x1";)]
public class Service1 : System.Web.Services.WebService
{ /*OMITTING VS DESIGNER CODE*/
  public MyRequestHeader m_soapReqHeader;

  [WebMethod]
  [SoapHeader("m_soapReqHeader", Direction=SoapHeaderDirection.In)]
  public String HelloWorld()
  {
    return "Hello World";
  }
}

[Serializable]
[XmlType(Namespace="http://epicor.com/inter/y1";)]
public class MyRequestHeader : SoapHeader
{
  public string sValue;
  public int    intValue;
}

When the WSDL gets generated, it wants the message to look like this (note
the namespaces):
  <soap:Header>
    <MyRequestHeader xmlns="http://epicor.com/apps/x1";>
      <sValue xmlns="http://epicor.com/inter/y1";>string</sValue>
      <intValue xmlns="http://epicor.com/inter/y1";>int</intValue>
    </MyRequestHeader>
  </soap:Header>
  <soap:Body>
    <HelloWorld xmlns="http://epicor.com/apps/x1"; />
  </soap:Body>

I was hoping to get a cleaner looking message where my SOAP header class
had a namespace declaration more at the top level of my header:

  <soap:Header>
    <MyRequestHeader xmlns="http://epicor.com/inter/y1";>
      <sValue>string</sValue>
      <intValue>int</intValue>
    </MyRequestHeader>
  </soap:Header>
  <soap:Body>
    <HelloWorld xmlns="http://epicor.com/apps/x1"; />
  </soap:Body>


Is there a way to do this using .NET attributes?  Thanks very much,

Erik Johnson
Epicor Software Corp.

Reply via email to