WebService Client Adding Soap Header

I am new to .NET and webservices. I am trying to call a webservice written in Java. This is a two stage proces. The first is retrieving a <nonce> value. The second stage is to add the retrieved <nonce> value (which is series of numbers/chars. e.g 1234gh563432134e) to the Soap Header tag <Authentication>. The messgae should look as follows:

SOAP-ENV:Envelope
SOAP-ENV:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/
xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsd=http://www.w3.org/2001/XMLSchema
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xmlns:SOAP-ENC=http://schemas.xmlsoap.org/soap/encoding/
xmlns:si="http://soapinterop.org/xsd"><SOAP-ENV:Header><authentication>
 <nonce>13b9b5c6fffad00010de8d65b9647e0a</nonce>
 <ident>test</ident>
 <auth>c219245a06ba7b918c15c6b5b9e3a7b5</auth>
</authentication>

I am using a proxy class to invoke the required method, it is with this method; woningzoekendeupdate that i am trying to figure out how to add the authentication info to the SoapHeader:

[System.Web.Services.
WebServiceBindingAttribute(Name = "bindingName", Namespace = "")]
public class SoapProxy : System.Web.Services.Protocols.SoapHttpClientProtocol
{
 public SoapProxy()
 {
  //Webservice location
  this.Url = "#";
 }

 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("woningzoekendeupdate", RequestNamespace = "#", Use = System.Web.Services.Description.SoapBindingUse.Default, ParameterStyle =  System.Web.Services.Protocols.SoapParameterStyle.Default)]
 [
return: System.Xml.Serialization.XmlElement("contractaanbieding", Namespace = "#", DataType = "string")]
 public string woningzoekendeupdate(object woningzoekendeupdate)
 {

  object[] results = this.Invoke("woningzoekendeupdate", new object[] { "dummy_parameter" });
  return ((string)(results[0]));
 }
}

Can anybody explain how to do this?

0
Sithicus
12/22/2006 9:05:34 AM
asp.net.xml-web-services 7071 articles. 0 followers. Follow

5 Replies
1189 Views

Similar Articles

[PageSpeed] 10

Hi,
PLS refer to this article about how to use custom soaphead in .net:
http://www.codeproject.com/cs/webservices/authforwebservices.asp
Hope it helps.
0
Raymond
12/25/2006 5:33:25 AM
Thanks for your reply, I have been able to add a custom header using the following code:

[System.Web.Services.Protocols.

SoapDocumentMethod(Action = "woningzoekendeupdate", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[System.Web.Services.Protocols.
SoapHeaderAttribute("AuthenticationHeader")]
[
return: System.Xml.Serialization.XmlElement("contractaanbieding")]
public string woningzoekendeupdate([XmlElement(ElementName = "namesp1woningzoekendeupdate", IsNullable = true)] XmlDocument aanbieding)
{
 object[] results = this.Invoke("woningzoekendeupdate", new object[] { aanbieding });
 return ((string)(results[0]));
}

I have written a "get set" method in the same class as where the above method is written in to access "AuthenticationHeader":

public
authentication AuthenticationHeader
{
 get
 {
   return this._authenticationHeader;
 }
 set
 {
   this._authenticationHeader = value;
 }
}

The authentication class has properties for the header which are set on initialisation of the class (so: new authentication). This means that before the header can actually be used the class needs to be initiated. The code isnt the most efficient one but for now it works I am planning to make the code cleaner and more logical. 

Oh and before I forget this is the eseential part of the authentication class:

[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.
XmlTypeAttribute(Namespace = http://xml.nccw.nl/xml/soap-auth/)]
[System.Xml.Serialization.
XmlRootAttribute(Namespace = "http://xml.nccw.nl/xml/soap-auth/", IsNullable = false)]

public partial class authentication : System.Web.Services.Protocols.SoapHeader
{
 //Put you public get set code here for you properties. String type can be used the essential header formatting for your SOAP header part is done by:
 -- System.Web.Services.Protocols.SoapHeader

I am now trying to figure out who to add a prefix to my SOAP request. Currently I am sending a XML document enclosed in the element "woningzoekendupdate". I am trying to make that element into: namesp1:woningzoekendeupdate. If anyone has an idea on how to accomplish that.. I am all ears.

Cheers


 
0
Sithicus
12/26/2006 5:49:53 PM

Hi,

Did you ever figure out how to add the prefixes? 

 

Sithicus:
Thanks for your reply, I have been able to add a custom header using the following code:

[System.Web.Services.Protocols.SoapDocumentMethod(Action = "woningzoekendeupdate", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[System.Web.Services.Protocols.
SoapHeaderAttribute("AuthenticationHeader")]
[
return: System.Xml.Serialization.XmlElement("contractaanbieding")]
public string woningzoekendeupdate([XmlElement(ElementName = "namesp1woningzoekendeupdate", IsNullable = true)] XmlDocument aanbieding)
{
 object[] results = this.Invoke("woningzoekendeupdate", new object[] { aanbieding });
 return ((string)(results[0]));
}

I have written a "get set" method in the same class as where the above method is written in to access "AuthenticationHeader":

public
authentication AuthenticationHeader
{
 get
 {
   return this._authenticationHeader;
 }
 set
 {
   this._authenticationHeader = value;
 }
}

The authentication class has properties for the header which are set on initialisation of the class (so: new authentication). This means that before the header can actually be used the class needs to be initiated. The code isnt the most efficient one but for now it works I am planning to make the code cleaner and more logical. 

Oh and before I forget this is the eseential part of the authentication class:

[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.
XmlTypeAttribute(Namespace = http://xml.nccw.nl/xml/soap-auth/)]
[System.Xml.Serialization.
XmlRootAttribute(Namespace = "http://xml.nccw.nl/xml/soap-auth/", IsNullable = false)]

public partial class authentication : System.Web.Services.Protocols.SoapHeader
{
 //Put you public get set code here for you properties. String type can be used the essential header formatting for your SOAP header part is done by:
 -- System.Web.Services.Protocols.SoapHeader

I am now trying to figure out who to add a prefix to my SOAP request. Currently I am sending a XML document enclosed in the element "woningzoekendupdate". I am trying to make that element into: namesp1:woningzoekendeupdate. If anyone has an idea on how to accomplish that.. I am all ears.

Cheers


 

0
zarar
1/17/2007 1:57:04 AM

Hi,

Did you ever solve the problem with the namespace prefixes? I'm having the exact same problem right now.

Regards, ThaYoung1!


Kind Regards,

ThaYoung1!
0
ThaYoung1
4/17/2008 8:01:38 AM
Just solved the problem with the prefixes. More information: http://forums.asp.net/t/1249049.aspx 

 


Kind Regards,

ThaYoung1!
0
ThaYoung1
4/21/2008 12:22:14 PM
Reply:

Similar Artilces:

web service SOAP Headers
If this isn't the right forum, let me know what is.Is there a difference between SOAP serialization and  and XML serialization.I have been reading heavily and am now quite confused.I understand that SOAP serialization produces XML, but perhaps without a specific schema or a scheme very different from XML. In the context of web services, the XML Serializer is used to produce XML in SOAP format. What you may be getting confused about is that there is also a "runtime serialization" subsystem. This can serialize data either using a Binary Formatter, or a SOAP Formatter. It...

Adding Web Reference to Web Service With SOAP Header in Visual Studio 2005
Hi, I'm a beginner in web service. Recently, I created a web service with custom SOAP header so it support security feature. I modify my code from a tutorial that I read: Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols _ _ _ Public Class SecureHelloWorld Inherits System.Web.Services.WebService Public authentication As AuthenticationHeader _ Public Function HelloWorld() As String If authentication.Name = "Hello" AndAlso authentication.Password = "World" Then Return &quo...

Sending SOAP attachments from Axis client to .NET web service
Hi all, I have an Apache Axis client that sends an attachment using javax.activation.DataHadler class. The web service is to be built in VB .NET and it will do a conversion to PDF and back the attachment to the client. My question is fairly simple: How can a .NET web service handle the attachment being sent to it as a DataHandler object from a java client? Can this be done? if not then how can i send an attachment from java client(axis) to a .NET web service? base64 encoding is not an option. This is my client side code:  public boolean transform(final boolean doTheDIME, S...

xml web service --uploading the file to the xml web service
how can we upload the file in the xml web service 1.i mean what will be the return value in the proxy class 2.and how am i going to send the file to the xml web service----regards Bipul Kumar Here are some links to articles that helped us get this done: http://msdn.microsoft.com/webservices http://www.microsoft.com/downloads/details.aspx?familyid=06255a94-2635-4d29-a90c-28b282993a41&displaylang=en https://www.sys-con.com/dotnet/article.cfm?id=458 Hope this helps....

XML Web Service Message from .NET to NonStop SOAP Server
Here's the XML parsing error the NonStop (Tandem) SOAP Server is generating as a result of a Web Service request from my .NET web client.  The web service in question works fine when the XML request comes from the "test" html client.  My question is, is this a lack of carriage returns a problem?  (see trace information below) >> 2008/10/15 14:32:3::Y7H3:<< Unmarshal Error: Invalid input document: Unexpected extra node(s) at the end of the document>> 2008/10/15 14:32:3::Y7H3:<< SoapDocumentHandler::process:Fault occurre...

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

xml stream from client to xml web service
I'm trying to send a serialized object based of an xsd to an xml web service by an xml stream. I've serialized it into a MemoryStream and trying to sent it to the service that I've made. The service should except this xml stream and create a serialized class of his own.   Giving the fact that I need to pass the Object as an xml stream, is it a good choisse to take a MemoryStream class for me? Trying to pass the MemoryStream instance made at the client side I get a compilation error as the instance made at the client side is recognized as a System.Io.MemoryStream while the argum...

How do I set a session ID in a web service SOAP header using a .NET proxy?
I have a web service proxy set up in PB 10.5. I need to set a session ID in the SOAP header so the web service can validate subsequent requests for this session. Is this possible? You can't modify the SOAP headers unfortunately. That capability is supposed to be forthcoming in an EBF/Maintenance Release, but I do not now of an specific timeframe. On 20 Apr 2006 13:40:54 -0700, "Libby Engelbret" <lengelbret@npomn.com> wrote: >I have a web service proxy set up in PB 10.5. I need to set a session ID in >the SOAP header so the web service can val...

(for Bruce) XML with complex types in SOAP envelope fails in PB web service client
Hi Bruce, I have a web service developed in WSAD which takes XML as input and outputs XML. Can this service be consumed by Powerbuilder, I tried and it fails. Soap Request get convered from RPC/literal style into RPC/Encoding automaticaly. Do you think PB can send and receive XML as a SOAP message ? If yes how ? It has complex types in it. Please help, Thanks, Dinesh Generally XML is exactly what you send in a SOAP message. That (rather than structures) is generally what I return from mine, and sometimes use as the arguments to. Are you sure it's XML (i.e. a formatted stri...

.NET CLIENT TO ACCESS a non. NET WEB SERVICE
I develop in .net and need to create a web client to connect to a web service built in Java. http://xchainj.com:8080/axis/services/ScsEnvirodatWaterQualityIndexServiceSoap Its pretty easy when the web service was also built in .net. You can just create a web reference with the gui and automatically can see its functions and stuff. when i put this url in the box and hit go i dont get to see its functions. maybe this shouldnt be the url of the WSDL?? I Have no idea. Im very new to all of this. If there are any examples of .net clients connecting to non .net web clients it woul...

Adding a VS.NET web reference for more than one web service?
I have a web app exposing several web services: SignOnService.asmx UserService.asmx AdminService.asmx etc I have a Winform app that consumes these services. When I go to Add Web Reference in the winform app, I have to add each one individually as their own web reference. How would I set this up so that they can all be added as one web reference? I think you will have to add them to one file (.cs or .vb) the reason they are comming up separately is becuase they are seperate, they are seperate web services(asmx files), classes and have seperate WSDL description...

Web service in .NET from Java Web Service
Hi there,I'm pretty new to .net (although i have years of experience with the old vb 6, access 2k, as well as java)... and need some with perhaps either some syntax or something.Here is the wsdl.<wsdl:definitions targetNamespace="http://www.dynix.com/schema/book">−<wsdl:types>−<schema targetNamespace="GetBookInfoByISBN">−<complexType name="BookInfoType">−<sequence><element maxOccurs="1" minOccurs="0" name="Title" nillable="true" type="xsd:string"/><element maxOccurs=&quo...

WS-Security with VS.NET 2005 Web Service and .NET 1.1 Client
We ship a webservices client piece into the field which is required to run on the .NET 1.1 version of the framework, this is defined by our business people and cannot change. We would like to work with .NET 2.0 in VS.NET 2005 for the backend Web Service piece. We are able to get the 2 to communicate fine and it is not a problem. The issue now is that we need to introduce security through WS-Security. I have not been able to find much information about interop between the 2 environments and WS-Security and cannot get the security elements to be invoked in VS.NET 2005. Currently we are trying ...

.NET web services Vs Java Web Services
Hello, does anyone know of a book or good source of information that compares .NET and Java Web Services? (I would like soemthing neutral if possible). I am thinking of approaching this subject for my dissertation? Many Thanks Rob Hi Rob, Last year I had to give a powepoint presentation on Web Services. I noticed some good books at barnes and noble that discussed the subject. These books were specific to Java and discussed Web Services in a very clear fashion. They gave some elementary examples that were easy to understand. I have not yet had the pleasure of creatin .NET Web Servi...

Web resources about - WebService Client Adding Soap Header - asp.net.xml-web-services

webservices Articles, Posts, Blogs, Videos - Technorati
— Authority: The job consist in a PHP program that read a file, compose a message (email or sms) and call an API of email provider (Amazon SES) ...

Section: software:webservices
Wired.com © 2012 Condé Nast. All rights reserved. Use of this Site constitutes acceptance of our User Agreement (effective 3/21/12) and Privacy ...

Products - CrunchBase
Product profiles

App Search on Flickr - Application Sharing!
Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to ...

Wikipedia:Press coverage 2005 - Wikipedia, the free encyclopedia
If you add an article, please cite both the title and the source. Note that if you're listing an article from a traditional press wire service ...

Entity–relationship model - Wikipedia, the free encyclopedia
In software engineering , an entity-relationship model ( ER model for short) is an abstract and conceptual representation of data . Entity-relationship ...

Entity-relationship model - Wikipedia, the free encyclopedia
In software engineering , an entity-relationship model ( ER model for short) is an abstract and conceptual representation of data . Entity-relationship ...

IT and Telecommunications Jobs in Melbourne Metro - MyCareer
Find IT and Telecommunications Jobs in Melbourne Metro on MyCareer. Fresh IT and Telecommunications Jobs posted daily. Free email alerts and ...

AWS Elastic Beanstalk: A Quick and Simple Way into the Cloud
Flexibility is one of the key principles of Amazon WebServices - developers can select any programming language and software package,any operating ...

How To Use the Amazon SDK for Android to Upload Photos to Amazon S3
This article demonstrates how to use the AWS SDK for Android to upload an image to Amazon Simple Storage Service (S3) from your mobile device ...

resources last updated: 11/20/2015 8:33:28 PM