• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Adding Soap Header to a Soap webservice

New Here ,
Aug 19, 2010 Aug 19, 2010

Copy link to clipboard

Copied

I have generated a Soap Webservice in Flashbuilder and need to add A Soap Header with 3 variables.

Can anyone tell me how this is done?

Views

3.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 19, 2010 Aug 19, 2010

Copy link to clipboard

Copied

http://livedocs.adobe.com/flex/3/langref/mx/rpc/soap/AbstractWebService.html#addHeader()

addHeader(header:Object):void

This adds to the headers:Array member of the WebService Class.

The header object is to be queued as header[headerName]=headerValue.

It is preferable however that you create a SoapHeader object, whose constructor takes a qname:QName and content:Object as arguments and constructs the header

You may also use the addSimpleHeader(qnameLocal:String,qnameNamespace:String,headerName:String,headerValue:String):void method.

This creates a SoapHeader object, whose QName is constructed from the Local and Namespace Strings and a content object with the headerValue keyed on the headerName property.

Hope this helps,

Balakrishnan V

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 20, 2010 Aug 20, 2010

Copy link to clipboard

Copied

Hello,

Thanx for yor response...

However i am a newbee in this matter.

Here is my code, can you look at it fill in the blancs, correct it?

----------------------------------------------------------------------------------

/**
* This is a generated class and is not intended for modification.  To customize behavior
* of this service wrapper you may modify the generated sub-class of this class - Ticketunie.as.
*/
package server.services.ticketunie
{
import com.adobe.fiber.core.model_internal;
import com.adobe.fiber.services.wrapper.WebServiceWrapper;
import com.adobe.serializers.utility.TypeUtility;
import mx.rpc.AbstractOperation;
import mx.rpc.AsyncToken;
import mx.rpc.soap.mxml.Operation;
import mx.rpc.soap.mxml.WebService;
import mx.rpc.soap.SOAPHeader;

[ExcludeClass]
internal class _Super_Ticketunie extends com.adobe.fiber.services.wrapper.WebServiceWrapper
{
    
    // Constructor
    public function _Super_Ticketunie()
    {
        // initialize service control
        _serviceControl = new mx.rpc.soap.mxml.WebService();
        var operations:Object = new Object();
        var operation:mx.rpc.soap.mxml.Operation;

        operation = new mx.rpc.soap.mxml.Operation(null, "HelloWorldAuth");
        operation.resultType = String;
        operations["HelloWorldAuth"] = operation;

        _serviceControl.operations = operations;
        try
        {
            _serviceControl.convertResultHandler = com.adobe.serializers.utility.TypeUtility.convertResultHandler;
        }
        catch (e: Error)
        { /* Flex 3.4 and eralier does not support the convertResultHandler functionality. */ }

        _serviceControl.service = "Service";
        _serviceControl.port = "ServiceSoap";
        wsdl = "http://secure.ticketunie.com/iresWs/service.asmx?WSDL";
        model_internal::loadWSDLIfNecessary();

    }

        model_internal::initialize();
       
       
                public var header1:SOAPHeader;
                public var header2:SOAPHeader;
                public var header3:SOAPHeader;
       
                public function headers():void {
           
                    // Create QName and SOAPHeader objects.
                    var q1:QName=new QName("http://soapinterop.org/xsd", "Header1");
                    header1=new SOAPHeader(q1, {string:"Trsid",int:"value1"});
                    header2=new SOAPHeader(q1, {string:"Coho",int:"value2"});
                    header3=new SOAPHeader(q1, {string:"Key",string:"value3"});
           
                    // Add the header1 SOAP Header to all web service request.
                    ???.addHeader(header1);
                    ???.addHeader(header2);
                    ???.addHeader(header3);
       
            }

    /**
      * This method is a generated wrapper used to call the 'HelloWorldAuth' operation. It returns an mx.rpc.AsyncToken whose
      * result property will be populated with the result of the operation when the server response is received.
      * To use this result from MXML code, define a CallResponder component and assign its token property to this method's return value.
      * You can then bind to CallResponder.lastResult or listen for the CallResponder.result or fault events.
      *
      * @see mx.rpc.AsyncToken
      * @see mx.rpc.CallResponder
      *
      * @return an mx.rpc.AsyncToken whose result property will be populated with the result of the operation when the server response is received.
      */
    public function HelloWorldAuth() : mx.rpc.AsyncToken
    {
        model_internal::loadWSDLIfNecessary();
        var _internal_operation:mx.rpc.AbstractOperation = _serviceControl.getOperation("HelloWorldAuth");
        var _internal_token:mx.rpc.AsyncToken = _internal_operation.send() ;

        return _internal_token;
    }
    
}

}

----------------------------------------------------------------------------------

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 20, 2010 Aug 20, 2010

Copy link to clipboard

Copied

http://livedocs.adobe.com/flex/3/langref/mx/rpc/soap/Operation.html#addHeader()

The operation can also add an header.

Use the appropriate operation to which you want to add the header.

Here, "operation" or "operations["HelloWorldAuth"] can be used

operations["HelloWorldAuth"].addHeader();

This should work !(I have not tried it out though !)

Try it and tell me if it works

Thanks

balakrishnan v

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 20, 2010 Aug 20, 2010

Copy link to clipboard

Copied

I've tried this, but it did not work. I get a response value

of -4, should be 1.

Hre is my code again (tried operations["HelloWorldAuth"].addHeader(); also).

----------------------------------------------------------------------------------------------------

/**
* This is a generated class and is not intended for modification.  To customize behavior
* of this service wrapper you may modify the generated sub-class of this class - Ticketunie.as.
*/
package server.services.ticketunie
{
import com.adobe.fiber.core.model_internal;
import com.adobe.fiber.services.wrapper.WebServiceWrapper;
import com.adobe.serializers.utility.TypeUtility;

import mx.rpc.AbstractOperation;
import mx.rpc.AsyncToken;
import mx.rpc.soap.Operation;
import mx.rpc.soap.SOAPHeader;
import mx.rpc.soap.mxml.Operation;
import mx.rpc.soap.mxml.WebService;


[ExcludeClass]
internal class _Super_Ticketunie extends com.adobe.fiber.services.wrapper.WebServiceWrapper
{
    
    // Constructor
    public function _Super_Ticketunie()
    {
        // initialize service control
        _serviceControl = new mx.rpc.soap.mxml.WebService();
        var operations:Object = new Object();
        var operation:mx.rpc.soap.mxml.Operation;

        operation = new mx.rpc.soap.mxml.Operation(null, "HelloWorldAuth");
         operation.resultType = String;
        operations["HelloWorldAuth"] = operation;

        _serviceControl.operations = operations;
        try
        {
            _serviceControl.convertResultHandler = com.adobe.serializers.utility.TypeUtility.convertResultHandler;
        }
        catch (e: Error)
        { /* Flex 3.4 and eralier does not support the convertResultHandler functionality. */ }

        _serviceControl.service = "Service";
        _serviceControl.port = "ServiceSoap";
        wsdl = "http://secure.ticketunie.com/iresWs/service.asmx?WSDL";
        model_internal::loadWSDLIfNecessary();

        model_internal::initialize();
    }
   
    public var header1:SOAPHeader;
    public var header2:SOAPHeader;
    public var header3:SOAPHeader;
   
    public function headers():void {
       
        // Create QName and SOAPHeader objects.
        var q1:QName=new QName("http://secure.ticketunie.com/", "Header1");
        header1=new SOAPHeader(q1, {string:"Trsid",int:"299"});
        header2=new SOAPHeader(q1, {string:"Coho",int:"1"});
        header3=new SOAPHeader(q1, {string:"Key",string:"70db3164e4421b33bd9f170db3164e4421b33bd9f1"});
       
        // Add the header1 SOAP Header to all web service request.
        operations.addHeader(header1);
        operations.addHeader(header2);
        operations.addHeader(header3);
    }

    /**
      * This method is a generated wrapper used to call the 'HelloWorldAuth' operation. It returns an mx.rpc.AsyncToken whose
      * result property will be populated with the result of the operation when the server response is received.
      * To use this result from MXML code, define a CallResponder component and assign its token property to this method's return value.
      * You can then bind to CallResponder.lastResult or listen for the CallResponder.result or fault events.
      *
      * @see mx.rpc.AsyncToken
      * @see mx.rpc.CallResponder
      *
      * @return an mx.rpc.AsyncToken whose result property will be populated with the result of the operation when the server response is received.
      */
    public function HelloWorldAuth() : mx.rpc.AsyncToken
    {
        model_internal::loadWSDLIfNecessary();
        var _internal_operation:mx.rpc.AbstractOperation = _serviceControl.getOperation("HelloWorldAuth");
        var _internal_token:mx.rpc.AsyncToken = _internal_operation.send() ;

        return _internal_token;
    }
    
}

}

----------------------------------------------------------------------------------------------------

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 24, 2010 Aug 24, 2010

Copy link to clipboard

Copied

Solved the problem...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 24, 2010 Aug 24, 2010

Copy link to clipboard

Copied

Could I know what you did to solve the issue ? It might be helpful for the forum to have a record of the solution as well !

Balakrishnan V

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 24, 2010 Aug 24, 2010

Copy link to clipboard

Copied

Hello,

The key was putting the soapheader variables in an object...

var obj:Object=new Object();

obj.headerName1 = value1;

obj.headerName2 = value2;

obj.headerName3 = "value3";

var qname:QName=new QName("http://secure.website.com/",

"AuthenticationHeader");

var header1:SOAPHeader = new SOAPHeader(qname, obj);

operations["certainCall"].addHeader(header1);

I shall post the solution in the forum...

--

Met vriendelijke groeten, Dik Hendriks

Hendriks grafische vormgeving / webdesign

(038) 332 49 79

***********************************************************************

Dit e-mail-bericht is alleen bestemd voor de geadresseerde(n). Indien

dit bericht niet voor u is bedoeld, wordt u verzocht de afzender

hiervan op de hoogte te stellen door het bericht te retourneren en

de inhoud niet te gebruiken. Aan dit bericht kunnen geen rechten

worden ontleend.

***********************************************************************

Op 25 aug 2010, om 05:16 heeft Balakrishnan V het volgende geschreven:

Could I know what you did to solve the issue ? It might be helpful

for the forum to have a record of the solution as well !

>

Balakrishnan V

>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 24, 2010 Aug 24, 2010

Copy link to clipboard

Copied

LATEST

The key was putting the soapheader variables in an object...

        var obj:Object=new Object();
        obj.headerName1 = value1;
        obj.headerName2 = value2;
        obj.headerName3 = "value3";
       
        var qname:QName=new QName("http://secure.website.com/", "AuthenticationHeader");
        var header1:SOAPHeader = new SOAPHeader(qname, obj);

        operations["certainCall"].addHeader(header1);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines