I am new to SOAP and web-services, and not an expert on c# either so sorry if I have made an infuriatingly simple error.
I am calling several web-services and I now need to add an element called *pcimask* to the SoapHeader in order to get a response that is PCI Compliant.
The web-services/WSDL don't expose this property so I guess I need to add it at runtime.
My application creates SOAP messages like the below: (the Soap Request and Response are output into a text file by a SOAP Logging class)
As I understand it, I need to add an element `pcimask="true` to the `<ClientContext ` element, and it must be after the `<ip>`
However the wsdl doesn't expose this as a property.
So I have looked at the below resources:
and I came up with a little class inside my common.cs as below:
and I wanted to try and use it in my code that creates the SoapHeader as below:
but I get a build error:
Attribute 'SoapHeader' is not valid on this declaration type. It is only valid on 'method' declarations.
so what is the correct way to do this?
I am calling several web-services and I now need to add an element called *pcimask* to the SoapHeader in order to get a response that is PCI Compliant.
The web-services/WSDL don't expose this property so I guess I need to add it at runtime.
My application creates SOAP messages like the below: (the Soap Request and Response are output into a text file by a SOAP Logging class)
Code:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<AutHeader xmlns="http://edb.com/ws/WSCommon_v21">
<SourceApplication>myApp</SourceApplication>
<DestinationApplication>theirApp</DestinationApplication>
<Function>CardCreate</Function>
<Version>3.0.0</Version>
<ClientContext>
<userid>myID</userid>
<credentials>SecureToken</credentials>
<channel>NBA</channel>
<orgid>123456</orgid>
<orgunit>654321</orgunit>
<customerid />
<locale xsi:nil="true" />
<ip>123.456.789.012</ip>
</ClientContext>
</AutHeader>
</soap:Header>
However the wsdl doesn't expose this as a property.
So I have looked at the below resources:
- http://bytes.com/topic/net/answers/5...r-soap-message
- http://stackoverflow.com/questions/1...b-service-call
- http://stackoverflow.com/questions/4...r-in-spring-ws
and I came up with a little class inside my common.cs as below:
Code:
using System.Web.Services.Protocols;
using System.Xml.Serialization;
namespace EvryCardManagement
{
[XmlRoot(Namespace = "http://edb.com/ws/WSCommon_v21")]
[SoapHeader("EDBHeaderType", Direction = SoapHeaderDirection.In)]
public class CardCreateEx : SoapHeader
{
public string Value;
public CardCreateEx pcimask;
}
public static class Common
{
public static bool closeMe { get; set; }
public static int iMQRowID;
public static string impNme;
public static string impPwd;
Code:
private EDBHeaderType wsSoapHeader()
{
EDBHeaderType wsSoapHeader = new EDBHeaderType();
/* ClientContext */
ClientContextType clientContext = new ClientContextType();
clientContext.userid = edb_service[0].userid;
clientContext.credentials = Common.SOToken;
//clientContext.pc
clientContext.orgid = edb_service[0].orgid;
clientContext.orgunit = edb_service[0].orgunit;
clientContext.customerid = "";
clientContext.channel = edb_service[0].channel;
clientContext.ip = edb_service[0].ip;
/* PCI MASK added to ClientContext in header; P-02925; Jan 2015 */
CardCreateEx cardCreateExt = new CardCreateEx(); // P-02925; Jan 2015
cardCreateExt.Value = "true";
/* EDBHeader */
wsSoapHeader.SourceApplication = edb_service[0].SourceApplication;
wsSoapHeader.DestinationApplication = edb_service[0].DestinationApplication;
wsSoapHeader.Function = edb_service[0].Function;
wsSoapHeader.Version = edb_service[0].Version; // P-02925; Oct-Nov 2014
wsSoapHeader.ClientContext = clientContext;
return wsSoapHeader;
}
Attribute 'SoapHeader' is not valid on this declaration type. It is only valid on 'method' declarations.
so what is the correct way to do this?