I am creating ASMX web service in .Net for javaclient. Provided soap looks like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pus="http://www.example.org/pusheventservice/">
<soapenv:Header>
<ServiceHeader>
<TransactionID>258350</TransactionID>
<TransactionDate>2014/12/21</TransactionDate>.......
and javaclient expects response SOAP
like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pus="http://www.example.org/pusheventservice/">
<soapenv:Header>
<ResponseServiceHeader>
<TransactionID>258350</TransactionID>
<TransactionDate>2014/12/21</TransactionDate>....
means requestElement is 'ServiceHeader' and ResponseElement must be 'ResponseServiceHeader'
I WebMethod i achieved this but unable in Header.
Is it Possible?? If Yes how?? Also I Cant use WCF....
EDITS
namespace PushWS
{
[WebService(Namespace = "http://localhost:60463/PushEvent.asmx")]
[WebServiceBinding(ConformsTo = WsiProfiles.None)]
[SoapDocumentService(SoapBindingUse.Literal, SoapParameterStyle.Bare, RoutingStyle = SoapServiceRoutingStyle.SoapAction)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class PushEvent : System.Web.Services.WebService
{
public ServiceHeader serviceHeader = null;
public SoapUnknownHeader[] userCredentials;
[WebMethod(Description = "updateEvent receives XML from Client")]
[SoapHeader("serviceHeader", Direction = SoapHeaderDirection.InOut)]
[SoapHeader("userCredentials", Required = true)]
[return: XmlElement("EventResponse")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost:60463/PushEvent.asmx/updateEvent",
RequestElementName = "updateEventRequest",
ResponseElementName = "updateEventResponse")]
public XmlElement updateEvent([XmlAnyElement]XmlElement MyPushEvent)
{
//Logic here
}
public class ServiceHeader : SoapHeader
{
public string TransactionID{get;set;}
public string TransactionDate{get;set;}
}
}
Create a derived class for the response header:
public class ResponseServiceHeader : ServiceHeader
{
}
public ServiceHeader serviceHeader = null;
public ResponseServiceHeader responseServiceHeader = null;
[SoapHeader("serviceHeader", Direction = SoapHeaderDirection.Int)]
[SoapHeader("responseServiceHeader", Direction = SoapHeaderDirection.Out)]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.