如何在Flex中设置SOAP服务的位置?

问题描述:

我已经使用FlexBuilder菜单成功生成了我的Web服务代理。这个特定的Web服务在其WSDL中指定了一个内部(或不正确的)“位置”。这意味着当我去做一个实际的方法调用时,它会失败,因为位置字段中指定的DNS名称是错误的。 (在火虫中显示为“已中止”)。如何在Flex中设置SOAP服务的位置?

如何在服务对象上设置位置属性?我已经在Java和PHP中完成了这一点,但无法弄清楚如何在Flex中做到这一点。


更新:

需要被改变下面列出的字段。它被称为“WSDL端点”。所以问题是:我如何以编程方式为生成的Web服务对象(扩展了WebServiceWrapper的对象)执行此操作?

<annotation name="ServiceConfig"> 
    <item name="DEFAULT_ENTITY_PACKAGE">valueObjects</item> 
    <item name="WSDL-endpoint">http://eoc7/eoc7/api.asmx</item> 
    <item name="LINKED_FILE"></item> 
</annotation> 
+0

显示一些代码,所以我们可以看到你在哪里错了。 – 2011-04-08 00:21:05

这里以编程方式设置在Flex SOAP服务的Web服务的“位置”的方式:

转到生成的服务类,并设置该属性的_Service控制对象:

_serviceControl.endpointURI = "http://uri-to-real-location" 

所以我创建了一个简单的方法来从类的外部设置此:

public function setEndpointUri(uri : String) : void 
{ 
    _serviceControl.endpointURI = uri; 
} 

Flash Builder将web服务地址存储在Flex项目的.model子目录中的.fml文件中。您可以编辑此文件,然后重新打开该项目。但最简单的方法是删除数据/服务并使用向导重建它。

+0

我不应该编辑该文件中的地址,重建不会有帮助,因为问题不在于服务的URL已更改。问题在于WSDL的URL与WSDL中的位置字段不同。例如,这是你如何在Java中使用axis:http://*.com/questions/1243980/how-can-i-change-wsdlsoapaddress-location-at-runtime – awynne 2011-04-08 14:24:28

+0

此外,编辑该文件并重新打开项目不起作用。我需要以非常规的方式来做到这一点 – awynne 2011-04-08 14:38:48

这是我能得到它的工作的唯一办法,为您SERVIC生成的存根E:

import com.adobe.fiber.core.model_internal; 

另外:

/** 
* 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();