如何在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>
答
这里以编程方式设置在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文件中。您可以编辑此文件,然后重新打开该项目。但最简单的方法是删除数据/服务并使用向导重建它。
答
这是我能得到它的工作的唯一办法,为您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();
显示一些代码,所以我们可以看到你在哪里错了。 – 2011-04-08 00:21:05