Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7158655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:06:09+00:00 2026-05-28T13:06:09+00:00

I’m having a lot of headache with the problem described in this topic title.

  • 0

I’m having a lot of headache with the problem described in this topic title.
I’m not very good with web services and I’m dealing with one developed internally in Java.
This web service requires a Header element named Token with a value (an encrypted string).
I’ve been able to add this “Token” but the service doesn’t accept it.

This is the request xml my proxy calls generates (proxy class built with WSDL.EXE and modified to accept a SoapHeader external class I wrote to add Header to request):

<soap:Envelope>
    <soap:Header>
        <TokenHeader soap:actor="http://schemas.xmlsoap.org/soap/actor/next">
            <Token>[TOKEN VALUE]</Token>
        </TokenHeader>
    </soap:Header>
    <soap:Body>
    </soap:Body>
</soap:Envelope>

and this is what the web services wants (this is a xml request made by a java tyest client):

<soapenv:Envelope>
    <soapenv:Header>
        <ns1:Token soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
            [TOKEN VALUE]
        </ns1:Token></soapenv:Header>
    <soapenv:Body>
    </soapenv:Body>
</soapenv:Envelope>

This is the code I wrote:

Imports System.Web.Services
Imports System.Web.Services.Protocols

<System.Xml.Serialization.XmlRoot(Namespace:=[WSDL NAMESPACE])> _
Public Class TokenHeader
    Inherits SoapHeader

    <System.Xml.Serialization.XmlElement("Token", Namespace:=[WSDL NAMESPACE])> _
    Public Token As String

    Public Sub New()
        MyBase.New()
        Me.Actor = "http://schemas.xmlsoap.org/soap/actor/next"
    End Sub
End Class    

and this is the piece of code of the proxy class where I’ve declared the Token

<System.Web.Services.Protocols.SoapDocumentMethodAttribute("", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Bare)> _
<WebMethod(), SoapHeaderAttribute("TokenHeader", Direction:=SoapHeaderDirection.In)> _
Public Function ChiamaEdicola(<System.Xml.Serialization.XmlElementAttribute([Namespace]:=[WSDL NAMESPACE])> ByVal ChiamaEdicolaRequest As ChiamaEdicolaRequest) As <System.Xml.Serialization.XmlElementAttribute("ChiamaEdicolaResponse", [Namespace]:=[WSDL NAMESPACE])> ChiamaEdicolaResponse
    Try
        Dim results() As Object = Me.Invoke("ChiamaEdicola", New Object() {ChiamaEdicolaRequest})
        Return CType(results(0), ChiamaEdicolaResponse)
    Catch ex As Exception
        MsgBox("Errore: " & vbCrLf & ex.Message)
        Return Nothing
    End Try
End Function

Finally the piece of code where I call this function:

Private Sub SendRivData(ByVal IRWebSrvData As ChiamaEdicola)
Dim IRWebSrvSend As New ChiamaEdicolaRequest
Dim IRWebSrvRecv As ChiamaEdicolaResponse
Dim IRWebSrvClient As New EdicolaService
Dim TokenHeader As New IR2IG.TokenHeader

    IRWebSrvSend.ChiamaEdicola = IRWebSrvData

    TokenHeader.Token = "[TOKEN VALUE]"
    IRWebSrvClient.TokenHeader = TokenHeader

    IRWebSrvRecv = IRWebSrvClient.ChiamaEdicola(IRWebSrvSend)

    If IRWebSrvRecv Is Nothing Then 
        MsgBox("Errore durante l'elaborazione!", MsgBoxStyle.Exclamation)
        Exit Sub
    End If

    With IRWebSrvRecv
        If CInt(.Stato) <> 0 Then
            MsgBox("Elaborazione OK:" & vbCrLf & .Messaggio, MsgBoxStyle.Information)
        Else
            MsgBox("Errore durante l'elaborazione:" & vbCrLf & .Messaggio, MsgBoxStyle.Exclamation)
        End If
    End With
End Sub

This is all (I had to omit few parts because my boss doesn’t want me to make them public).

If someone knows how to accomplish this, please, help me.
It’s about 4 days I’m working on it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:06:10+00:00Added an answer on May 28, 2026 at 1:06 pm

    Don’t mess with the generated proxy class but instead extend this class and give your own implementation, in your case override GetWriterForMessage and add your required header to the message e.g. The following code is just to give you the idea how to fit the pieces:

    Public Class ExtendedWebService
         Inherits myWebService
    
         Protected Overrides Function GetWriterForMessage(message As SoapClientMessage, bufferSize As Integer) As System.Xml.XmlWriter
    
             message.Headers.Add(YourCustomHeader)
    
             Return MyBase.GetWriterForMessage(message, bufferSize)
         End Function
    
    End Class
    

    Hope it helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.