Setting a WebServiceWrapper Endpoint at Run Time

I am in the middle of moving from Flex Builder 3 to Flash Builder 4, and one of the problems I have been facing is that the support for web services in 4 is significantly different. In both IDEs, I can import WSDL for my web service, and it will generate the appropriate client classes to communicate with the service. The generated code is different in each case.

In my Flex3 code, I managed to access the endpointURI property mx.rpc.soap.AbstractWebService, but in the generated Flex4 code, the new class extends com.adobe.fiber.services.wrapper.WebServiceWrapper, which does not have the endpointURI property.

There are several game servers in my project, and the player chooses which server they want to play on. Previously, if a player needs server 1, I would set the endpoint URI to http://game1.server.com/service.asmx and, as wise, if they wanted server 2 I would set the endpoint to http: //game2.server. com / service.asmx .

What am I looking for for this in Flash Builder 4?

+3
source share
3 answers

Short answer:

var s:ClassThatExtendsWebServiceWrapper = new ClassThatExtendsWebServiceWrapper;
s.serviceControl.endpointURI = 'http://service.com/service.asmx';

Long answer:

Well, finally, I found a solution. Adobe seemed to make it a lot more complicated than it should have been.

-, Flash Builder 4, com.adobe.fiber.services.wrapper.WebServiceWrapper. WebServiceWrapper , serviceControl, . , serviceControl . , - GameService. -, WSDL, Flash Builder .

internal class _Super_GameService extends 
com.adobe.fiber.services.wrapper.WebServiceWrapper
{ ... }

public class GameService extends _Super_GameService
{}

_Super_GameService -. GameService , _Super_GameService, . , , , GameService, , , _Super_GameService , GameService .

. GameService . DoSomethingAwesome - , -.

var gs:GameService = new GameService();
var token:AsyncToken = gs.DoSomethingAwesome();

, URI , WSDL. , GameService URI. , .

, WebServiceWrapper (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/com/adobe/fiber/services/wrapper/WebServiceWrapper.html) Firefox. , , . Adobe.

serviceControl WebServiceWrapper. serviceControl mx.rpc.soap.AbstractWebService. AbstractWebService endpointURI, .

var gs:GameService = new GameService();
gs.serviceControl.endpointURI = 'http://game1.service.com/GameService.asmx';

, , , - endpointURI ServiceControl Intellisense. serviceControl -, endpointURI intellisense, , .

AbstractWebserivce, (http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/frameworks/projects/rpc/src/mx/rpc/soap/AbstractWebService.as), , Exclude, , endpointURI Intellisense. , .

+4

URI WebService. , , <s:WebService/>.

0

This is the only way to make it work, in the generated stub for your service:

import com.adobe.fiber.core.model_internal;

also:

    /**
 * Override super.init() to provide any initialization customization if needed.
 */
protected override function preInitializeService():void
{           
    _needWSDLLoad = false; // to prevent loading the default WSDL
    super.preInitializeService();
    // Initialization customization goes here
    wsdl = "http://localhost/yourservice?wsdl";
    _needWSDLLoad = true;
    model_internal::loadWSDLIfNecessary();  
0
source

Source: https://habr.com/ru/post/1765371/


All Articles