Adding Web Reference to Web Service With SOAP Header in Visual Studio 2005


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 "Hello World"
            Throw New Exception("FAIL")
        End If
    End Function
End Class

Public Class AuthenticationHeader
    Inherits SoapHeader

    Private strName, strPassword As String

    Public Sub New(ByVal strName As String, ByVal strPassword As String)
        Me.strName = strName
        Me.strPassword = strPassword
    End Sub

    Public Property Name()
        Set(ByVal value)
            strName = value
        End Set
            Return strName
        End Get
    End Property

    Public Property Password()
        Set(ByVal value)
            strPassword = value
        End Set
            Return strPassword
        End Get
    End Property
End Class

The problem is, when I right click my solution in the Solution Explorer, and then click "Add Web Reference", select my .asmx file in the "Add Web Reference" tool box, I receive the following error in the "Add Web Reference" tool box I mentioned:

Server Error in '/Test' Application.

The header property/field SecureHelloWorld.Authentication is missing or not public. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.


How to add web reference to a web service with SOAP header?

Thanks in advance,

9/4/2008 7:48:45 AM 7071 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 24

Here's an example I found in my MSDN Library:


<%@ WebService Language="VB" Class="MyWebService"%>
Imports System.Web.Services
Imports System.Web.Services.Protocols

' Define a SOAP header by deriving from the SoapHeader base class.
' The header contains just one string value.
Public Class MyHeader
    Inherits SoapHeader
    Public MyValue As String
End Class

Public Class MyWebService
    ' Member variable to receive the contents of the MyHeader SoapHeader.
    Public myHeader As MyHeader

    ' Member variable to receive all headers other than MyHeader.
    Public unknownHeaders() As SoapUnknownHeader

    ' Receive any SOAP headers other than MyHeader.
    <WebMethod, _
        SoapHeader("myHeader", Direction := SoapHeaderDirection.InOut), _
        SoapHeader("unknownHeaders")> _
    Public Sub Hello()        

        ' Process the MyHeader SoapHeader.
        If myHeader.MyValue = "Some string" Then
            ' Process the header.
        End If 
        Dim header As SoapHeader
        For Each header In  unknownHeaders
            ' Perform some processing on header
            ' For those headers that cannot be processed, 
            ' set the DidUnderstand to false.
            header.DidUnderstand = False
        Next header
    End Sub
End Class

John Saunders | MVP – Connected System Developer
9/4/2008 11:28:51 AM


I guess you not understood the question. The example which you have posted, try to create a webservice using that example and then call .asmx file in browser. You will get the same error details what the original poster is asking about.


 Have anyone able to resovle this issue?


10/9/2008 7:16:51 PM

Similar Artilces:

unable to add a secure java web service to .net thru visual studio add web reference
I have a secure java web service running on my system.   I am able to successfully do a URL based invocation of it and also was able to get the expected SOAP response. It uses the Basic Authentication mechanism to make it secure. So basically when I type the URL in the address bar and invoke it, it asks me for a user name password, I enter it and it runs normally.  Now, when I try to add that web service to a simple web application thru visual studio add web reference mechanism, it first prompts with a certificate, which I accept and then prompts with Disco...

What action by a web service requires an app to update their web reference to a Web Service
I create a web reference to a web service in my aspx web application which returns an XML object. If the owner of the web service makes a change to their object am I required to do an update web reference? What if I dont use the information from the new object? thanks Larry You should make the change only if the contract b/w the two has changed (e.g. parameters, return values), etc.-Mathew Nolton If the web service now returns a new element and my class reference doesn't match their new class ref...

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: Hope this helps....

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...

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...

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="">−<wsdl:types>−<schema targetNamespace="GetBookInfoByISBN">−<complexType name="BookInfoType">−<sequence><element maxOccurs="1" minOccurs="0" name="Title" nillable="true" type="xsd:string"/><element maxOccurs=&quo...

Converting windows application using web service from Visual 2003 to Visual 2005
Hello, everyone! I have a solution which contains a windows project,a web service project and several other library projects. These projects were coded under visual 2003. Now I need to converted them to use Visual 2005. Does any one know any article providing step-by-step guide  to converting WINDOWS APPLICATION with web service? I can find one under MSDN for converting web project.  But I guess I am a little confused if mine should follow this article since I am using web service in my windows application? Thanks a lot in advance.  ...

adding web reference, remote web service. "unable to download service.asmx?wsdl"
Hello having a problem with this web service. VS [2005]  The message we get when we try and add the web reference is "unable download following files". Which is using the internal ip address of the web server. We have check the IIS where the web service has been published to. But could not see why it is using the internal ip and not the external ip address. The actual url is Here is the service description sample, maybe someone can check this, as this has the internal ip address at the bottom. ...

reference a compiled web service from another web service
I created a compiled web service (eg, a dll file). now i create another web service in which i want to refer to the compiled service. how is this done in vs .net?? i am following an example which is not vs .net specific so i am not sure of the syntax. the example says to create the second web service (ie, .asmx.vb file) and include the following single line of code in it to refer to the compiled code: <%@ WebService Class="compiled_code_service_name" %> this does not work within vs .net. can anybody tell me what is the correct syntax?? thanks I'm not quite sure I ...

.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 services in visual web developer 2005
hi. i have a problem with web serivces in visual web developer 2005. i made a web site with a web service and another web site where i want to create a reference of the web service, so i can call the web service. but when i try to add the reference, i get an error. apparently, it does not recognize the extension of my web service file. can anyone help me, please? i've spent all the week trying to resolve this problem. any help would be great. thanks in advance. the error says like this:   The XML page cannot be displayed Cannot view XML input using XSL style sheet. Pl...

Adding a web reference to a java web service
Hi, In my .net web application, I was trying to add a web reference to a Java web service running on a SUNONE machine in my intranet. But while the dialog box was searching for the reference, i encounter the following errors. No Web References were found on this page. The request failed with HTTP status 502: Proxy Error ( The ISA Server denies the specified Uniform Resource Locator (URL). ). But the wsdl for the web service was available. Any help will be greatly appreciated. Thanks.. ...

Web Site Project: How to configure web service URL in web.config (web service defined in a referenced DLL)
I have a web site that references a business logic DLL project. In the business logic project, there is a web service defined in its app.config file something like this: <applicationSettings>  <MyNamespace.BLL.Properties.Settings>    <setting name="MyNamespace_BLL_MyServer_ServiceName" serializeAs="String">    <value>http://blah.blah.blah.asmx</value>  </setting>  </MyNamespace.BLL.Properties.Settings></applicationSettings> When the web site is published, the web ...

how to make refer to a remote Web Service? : ServiceReference can only refer to local web service.
Hi Folks, Since  ServiceReference can only refer to local web service, how can I refer to web service in the remote machine?  Thanks for your suggestion.   Sun You can make a local web service that collect data from the remote web service.Hope this can helo ;)Stefano ...

Web resources about - Adding Web Reference to Web Service With SOAP Header in Visual Studio 2005 -

European Terrestrial Reference System 1989 - Wikipedia, the free encyclopedia
The European Terrestrial Reference System 1989 ( ETRS89 ) is a ECEF (Earth-Centered, Earth-Fixed) geodetic Cartesian reference frame , in which ...

Microsoft dismisses iPad Pro as “a companion device” and references old Steve Jobs stylus quote
... to be a companion device.” Laycock also said that “at one point in time, Apple declared that if there’s a stylus, that’s failure” – a reference ...

Shane Smith Also Dropped a David Carr Reference
On The Drudge Report and elsewhere, much is being made today about the fact that Shane Smith drops 52 F-bombs in this week’s Hollywood Reporter ...

All of The Simpsons’ best movie references compiled in one video
After 27 seasons on the air, it only makes sense that The Simpsons would reference every show, movie, book and pop culture artifact that it possibly ...

There's a wonderful hidden 'Indiana Jones' reference in 'Star Wars: The Force Awakens'
Sound editors for "Star Wars: The Force Awakens" managed to slide an "Indiana Jones" Easter egg into the film. In an interview with Nerdist ...

Deadpool's Best Easter Eggs And Pop Culture References
... in for a very different superhero movie when Deadpool finally made it to the screen. One full of violence, vulgarity, and pop culture references, ...

Worst passwords of 2015: Star Wars references sneak onto list
Enough with "123456" already! SplashData's annual list of the worst passwords in use includes some old favorites and some new sci-fi-inspired ...

The Flash: Easter Eggs and DC Comics References In "Welcome to Earth-2"
Tonight was the most Easter egg-heavy episode of The Flash to date.Let's get right into it [...]

Ricky Gervais Defends His Golden Globes Joke About Caitlyn Jenner With a Bill Cosby Reference
Ricky Gervais Defends His Golden Globes Joke About Caitlyn Jenner With a Bill Cosby Reference

9 Ways Your References Can Help You Land Your Next Job
Are your references selling your best attributes—or selling you out? Here's how to make them more effective for you. You're going for a new ...

Resources last updated: 2/14/2016 12:36:46 AM