Webservices SOAP and Namespace prefixes

G

Guest

Hi all

I've got a webservices that will be called by a delphi product. They have
defined a soap message that they will use to call my webservice. A header
snippet is found below:
<soap:Header>
<mm:TheHeader xmlns:mm="http://The URL">
<SomeValue>123</SomeValue>
<AnotherValue>blabla</AnotherValue>
</mm:TheHeader >
</soap:Header>
I've defined a Class that inherits from SoapHeader, and added the SoapHeader
attribute to my webmethod, and included a public member of that type in my
webservice class.
No matter what I do, I can not get the header variable populated. I've even
used SoapUnknownHeader in my webmethod, but to no joy.
I've got a idea that it's got to do with the namespace prefix (mm) they are
using. I included the namespace specified in the header, but still no luck.
They are following the soap standard, and other companies are using their
product, so there is no option of changing the soap enevelope.
Is there any way that I can get the soapheader variable populated?

Thanks in advance
 
G

Girish bharadwaj

I am not sure what you were looking for.
<%@ WebService language="C#" class="SoapHeaderTest" %>
using System;
using System.Xml;
using System.Xml.Serialization;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace="urn:my-header-test")]
public class SoapHeaderTest
{
public MyHeader myHeader;

public SoapHeaderTest()
{
myHeader.myString = "Hello, there";
}

[SoapHeader ("myHeader",Direction=SoapHeaderDirection.InOut)]
[WebMethod]
public void MyMethod()
{
myHeader.myString = "Hello, from myMethod";
return;
}

[XmlRoot(Namespace="urn:my-header")]
public class MyHeader:SoapHeader
{
public string myString;
}
}


Here is something that seems to work for me. This sets the namespace info
correctly.
 
G

Guest

Thanks for the quick reply Girish

I've got exactly the same code structure than what you recommended, but this
still does not solve my problem. If you look at the soap header in my initial
post, you will see the addition of a namespace prefix (mm) in the soap
header. This is what's causing the problem, because everything works fine if
I remove the namespace prefix, and use a normal default namespace declaration.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top