How to add a custom element to a SOAP Header in c#

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)
<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>
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:
 Bytes.com - how-add-soap-header-soap-message
 Stackoverflow: (18980689) adding-custom-soapheader-in-c-sharp-for-a-web-service-call
 Stackoverflow: (4035423) add-child-elements-to-custom-soap-header-in-spring-ws
and I came up with a little class inside my `common.cs` as below:
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;
and I wanted to try and use it in my code that creates the SoapHeader as below:
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;
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?

Hi,
>>Attribute 'SoapHeader' is not valid on this declaration type. It is only valid on 'method' declarations.
Base on this situation, just as the error message says, the 'SoapHeader' attribute can only use on method, such as:
[SoapHeader("myHeader", rection=SoapHeaderDirection.InOut)]
//Receive any SOAP headers other than MyHeader.
[SoapHeader("unknownHeaders",Required=false)]
public string MyWebMethod() {
return "Hello";
For mire information:
http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapheader(v=vs.110).aspx
Besides, about Defining and Processing SOAP Headers:
http://msdn.microsoft.com/en-us/library/77hkfhh8(v=vs.71).aspx
http://stackoverflow.com/questions/18980689/adding-custom-soapheader-in-c-sharp-for-a-web-service-call
Regards

Similar Messages

  • How to add Custom Attributes in the SOAP header for OWSM

    Hi,
    I like to know how to add the Custom Attributes in the SOAP header for OSWM username token authentication.
    Currently we are getting the header element like
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    here we need to add the attribute "soap:mustUnderstand="1" , so the element will look like
    <wsse:Security soap:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    Any info on this will be helpful.
    Thanks,
    ArunM

    Hi Jay, you can make it in more than 1 way.
    I suggest you the following:
    - create an URL iview that points to any URL you want.
    - define a Resource that points to the iview (with a window name, to open in new window)
    - define an Area that points to the resource
    - add your new Area to the your current Area Group
    Regards!

  • How to add a custom multimedia playback control to add a time line of what is being played?

    How to add a custom skin in multimedia playback control to add a time line of what is being played?  As it is being played...
    I need a time line so any part of the what is being played can be found by time, ie at 1 minute and 30 seconds in and continues for 45 seconds out of a 50 minute audo.

    If you're talking about a playback controller within the rich media annotation (RMA) then you need to write your own widget in Flash or Flex, and then place the video and widget files using the multimedia "Add Flash" tool in Acrobat instead of the "Add Video" tool. Aside from a bunch of proprietary code to handle events, commenting and the API (which you can live without for basic play-pause-scrub applications), video RMAs are just an embedded SWF file containing an FLVPlayback component. The skin and the video file itself are added to the RMA as resource entries. You can build your own version and have it display whatever controls you want, provided you know how to write ActionScript!
    If you're talking about a controller that's external to the RMA (e.g. a series of links or buttons elsewhere on the page) then in the past you would use FLV video files and the 'cue points' feature that's built into Acrobat - however Adobe removed the ability to create FLV files in the latest version of CC, so unless you have CS6 or earlier it's a non-starter. Instead you can manually set playback start points using the special "multimedia operations" link action in your PDF - though stopping playback at a defined point is very difficult without FLV cues. For that you're back to writing your own widget.

  • How to add a customer field or extn coll in the tab1&2&3..of a UDO doc?

    Hi Experts,
    Does anybody know how to add a customer field or extn collection in the unused  tabs like tab1&2...in a UDO document?
    Thanks for your reply in advance.
    Thanks & Regards,
    David

    Hi Subhasini - <br><br>
    It seems you have discovered that adding an extension field to the Project Suppliers collection is not possible; many of the collections in E-Sourcing do not support extensions and, even when they do, typically, the table view of the data cannot be changed to show the extension value (it would only show on a "details" page, for example.<br><br>
    The solution that you have proposed may work, although I think there is a slight mistake in your logic. I believe you are saying that the script would take data from the newly created extension collection and populate data in the out-of-the-box vendor collection. <br><br>
    In thinking about your solution, I believe the benefit is that any logic and reporting based on the standard collection continues to function correctly (e.g., creating an RFx from the Project will use the out-of-the-box vendor collection).<br><br>
    That being said, I generally am reluctant to do a "replace" of a standard collection with an extension collection as you propose. My recommendation is that you challenge the customer on the importance of this requirement. For example, could the code be maintained on the vendor record? Why is it maintained in Projects? If it is maintained in the vendor record, could you just populate a read only collection the Projects that shows the vendor and code? Could a report be written that can be launched from within the Project to show the values? How does the customer intend to use this field? Could the display name of the vendor object be the right place for it?<br><br>
    I hope these ideas are helpful.<br><br>
    Regards,<br><br>
    Rob<br><br>

  • How to add a new element to a model node in the view controller?

    View Context
        myNode
             attri1
             attri2
    myNode is a web service model node. How to add a new element to this node?
    Regards,
    Hui
    Edited by: Hui Wang on Feb 15, 2008 12:05 PM

    Sudhir Gorantla wrote:>
    > Hi,
    >
    > myNode
    > attri1
    > attri2
    >
    > IMyNodeElement ele=wdContext.myNode().createMyNodeElement();
    >
    > ele.setAttri1("");
    > ele.setAttri2("");
    >
    > wdContext.nodeMyNode().addElement(ele);
    >
    > Regards,
    > Sudhir
    Hi we need a model as an input parameter when creating a element for a model node. How to get the instance of the model?
    Regards,
    Hui

  • How to add a custom button in WD screen to call a workflow in siebel?

    Hi All,
    We have a requirement to have a custom button at the summary screen(after the rule execution) "Create Opportunity", on clicking on it a new opportunity record should be created in Siebel. As we know the "Save" link calls "PolicyAutomationSaveSession" inbound web service method and saves the information in session table and we can modify the PreSession and PostSession workflows. But we are not sure how it calls the service method and where is the mapping defined.
    Can you please help me on how to add a custom button and how to invoke a workflow in siebel side to implement this requirement?
    Also is there any document which can help me to add a custom button in screen and to add the code behind the button?
    Thanks in advance!!
    Regards,
    Subhradeep

    Subhradeep,
    Closing a Web Determinations window is essentially the same as closing any HTML window. It involves javascript, which you would have to add to the Web Determinations templates.
    Essentially the javascript command to close a window is {{window.close}} or {{top.close}}
    For timing, you might be able to use the setTimeout function of Javascript (see: http://www.w3schools.com/jsref/met_win_settimeout.asp)
    At the risk of exposing exactly how bad my javascript skills are, I have attached a super-simple html fragment, a page that closes itself after 3 seconds. It may help you get started in the right direction. In general closing a window is a fairly dubious activity and is often not permitted by certain browsers. This html page at least works in Internet Explorer.
    <html>
         <head>
         <script language="JavaScript">
              setTimeout(closeMe, 3000);
              function closeMe() {
                   alert("This window will close");
                   top.close();
         </script>
         </head>
         <body><B>This window will close in three seconds</B></body>
    </html>
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to add a Custom field in the Standard SAP Sales Order main screen

    Dear Experts,
    We have a requirement of adding a Custom field in the Sales Order screen. I know how to add the Customer field in the Additional data B tab of the Sales Order Header Screen as that is the screen user exit provided by SAP. Can someone tell me how to add the Custom field in the Sales Order main screen. Program Name - SAPMV45A and Screen Number - 4001. What is all I need to take care.
    Thanks,
    SNK.

    I have not added the Custom filed in the main screen and added in the Additional data B screen. So closing the message.

  • How-to add a custom Web Dynpro iView to the MSS Employee Profile

    Hello everybody,
    i have created a small How-to guide of how to add a custom iView/Web Dynpro application to the standard MSS Employee Profile for ECC 6.0.
    The How-to guide can be found <a href="https://wiki.sdn.sap.com/wiki/display/profile/2007/04/15/How-toaddacustomWebDynproiViewtotheMSSEmployee+Profile">here</a>
    I hope its of any value.
    cheers,
    Markus

    Hello Luca,
    unfortunatelly it wont work. A WDA Application does not have access to the Floorplan Manager for XSS Applications. So until SAP develop an interface, you have to stick for such a task to WDJ.
    regards,
    Markus

  • How to add a custom code to standard sap menu

    Hello guru,
    will you please explain me how to add a custom code to standard sap menu?
    thanks in advance.
    Best regards.
    juan

    Hello juan,
    with SE43N you can add custom transaction codes to the existing menues.
    see http://help.sap.com//saphelp_erp2004/helpdata//EN/00/783b377bfdcf61e10000009b38f936/frameset.htm
    regards
    johannes

  • Designer 2010 - how to add a custom or calculated field ?

    Hello
    I have a list like this:
    [name][course][date][result]
    John Smith, Windows beginners, 01-01-2014, 10
    John Smith, Windows advanced, 02-01-2014, 7
    Jane Doe, Windows beginners, 01-01-2014, 5
    Wanted:
    A list that shows all the people that attended 2 courses and a sum of their results.
    Following the example above:
    John Smith, 17, (2 courses)
    How can you add a custom field in designer? I have been tinkering but can't find it. If I place the cursor in a bottom row of the list, and in the ribbon I choose Options/Formula, I can enter an Xpath expression. But after clicking OK, nothing happens, nothing
    appears.
    Is there a tutorial (for beginners) somewhere on how to add a custom field to a page?
    Thank you!
    D

    I think the easiest way to accomplish this is through using the jQuery SPServices library to call the list items into an array and group by name. Then you can count the number they have done and then also do your calculations.
    Andy Wessendorf SharePoint Developer II | Rackspace [email protected]

  • How to add a Custome filed to OnDemand Analytics Report in Demo application

    Hi,
    I am working on Demo application.
    Know how to add a Custome filed to OnDemand Analytics Report in Demo application?
    Is there any additional privilage needed for Administrator which is not available for DEMO application.
    Thanks in advance,
    Sanjay

    Demo is same as the licensed version. If a new field is added in the object, it will automatically added in the Analytics

  • How to add actions to Elements 10

    How does one add actions to elements 10? I have access to some PS action files but the help file does not explain how to add them to Elements. Helps says to Click Add on the Actions panel, but there is no where "add" option.

    Install Actions in PSE
    scroll down to Install Actions in PSE 9 and 10.

  • How to add a new Element to the Context

    Hello all.
    I created in the wdInit()
    ArrayList datas = new ArrayList();
         for (int i = 0; i < 25; i++) {
              MyData data = new MyData();
              data.setMethods();
              datas.add(data);
         wdContext.nodeMyData().bind(datas);
    Now, I want by clicking on the Button "Create new Element", forward user to the other View, which elements are connected with the same model -> context, the new element should be added to context, the user should fill the form and click Save-Button.
    How can I add a new Element to the Collection I created and choose it as a current element?
    If I do: wdContext.nodeMyData().bind(new MyData()) all information will be lost. And I will have only one field.
    If I do it like this:
    IWDNodeElement dynTabElem=(IWDNodeElement)wdContext.nodeMyData().createElement();
    wdContext.nodeMyData().addElement(dynTabElem);
    I get an error: com.sap.tc.webdynpro.progmodel.context.ContextException: NodeInfo(DataComp.MyData): value node is created without a reference
    Well I can pass to my new View a Collection as a parameter and then
    Collection.add(new MyData()) and then bind it. But I find this solution not good.
    Is there any possibility to get the existing Collection from the Context without passing it to the view?
    Can I just add a new element to the existing collection?
    Thanks in advance.

    Hallo Monalisa,
    I did as you said. But I can't add something to my model class, because it is not collection.
                            MyData data = wdContext.currentBelegElement().modelObject();
                   data.add() ???? - don't work
                   wdContext.nodeMyData().invalidate();

  • How to add a custom column in a table?

    Hi,
    I have a requirement to add a custom field into the table of view InrLastHist of component ICCMP_BT_IRHIST. The data to be display in the column will be based on the standard category column.
    I was thinking of adding a value attribute into the current BTORDERCUSTHIST, and write its get method to display the custom data, BUT the add attribute wizard doesnt allow me to do so. There is a note saying "Value attribute: Attribute that is not contained in any BOL entities (not supported in this version)".
    So how do I do it? Pls advice.

    Hi,
    You need to find this bol in trx GENIL_MODEL_BROWSER, find the structure associeted and you have to create a field in this structure, after you create the attribute using this field that you created.
    Regards,
    Caíque Escaler

  • How to add a custom attributes in Oracle HTML Quotes page?

    Hi,
    Could someone advice on the best way to add a custom attribute in Oracle HTML Sales Quoting page.
    As this page is not an OA page, we are not able to use the concept of View Objects using AK Developer.
    Thanks,
    Arathi

    I have a requirement from our end users that all of them requires a shortcut button in toolbar for submitting a request instead of going the normal way in order to submit a single request.
    please can any one help me out in solving this query.Any reason you want to use a shortcut rather than using (Requests > Submit) window?
    You can use "FND_REQUEST.SUBMIT_REQUEST" API -- https://forums.oracle.com/forums/search.jspa?threadID=&q=FND_REQUEST.SUBMIT_REQUEST&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    How To Submit A Concurrent Request Set Using Fnd_Request.Submit_Request [ID 382791.1]
    How To Set ORG_ID When Submitting A Concurrent Request Using FND_REQUEST.SUBMIT_REQUEST in Release 12 [ID 1383266.1]
    Thanks,
    Hussein

Maybe you are looking for