gpt4 book ai didi

api - Salesforce WebServiceCallout.invoke 方法的参数是什么?

转载 作者:行者123 更新时间:2023-12-02 14:01:17 24 4
gpt4 key购买 nike

我想知道 Salesforce 用于调用远程 Web 服务的调用方法的参数。我有一个应该能够调用的服务,但该服务 WSDL 没有定义安全要求,因此我希望可以手动添加该信息(该服务使用通过 Soap header 传递的 WS-Security)。

这是我(认为我)到目前为止所知道的:

WebServiceCallout.invoke(
Class servicePort, //Usually set to "this", contains httpheader info as well as ?
request_x, //Request object, defining schema, properties, and field order
response_map_x, //Response object, defining schema, properties, and field order
new String[]{
String endpoint, //Endpoint of the service
String ?, //what is this?
String methodSchema, //Schema for the request object?
String method, //Name of the request method?
String responseSchema, //Schema for the response object?
String response, //Name of the response object?
String responseClass} //Name of the Apex class the response will be converted to
);

有人可以帮忙填补空白吗?

最佳答案

这是我迄今为止发现的 WebServiceCallout.invoke 内容:

Object servicePort - A class with the following variables:
String enpoint_x: containing the service endpoint (not sure if necessary)
Map<String,String> inputHttpHeaders_x: custom httpHeaders
Map<String,String> outputHttpHeaders_x: I think this is the httpHeaders that were returned
String clientCertName_x: Used in configuring an SSL cert?
String clientCert_x: Used in configuring an SSL cert?
String clientCertPassword: Used in configuring an SSL cert?
Integer timeout_x: How long (in milliseconds?) to wait for the response
String[] ns_map_type_info: The first String is the namespace of the service schema, the second is the name of the object that contains the Apex classes defining the schema objects
Object request_x - The Apex object that will form the XML schema object
Map<String, Object> response_map_x - Object is the object that the result is to be unserialized into. String is the name of Object variable.
String[] {
endpoint - The service endpoint
soapAction - If the service call requires a soapAction, put it here. Otherwise leave blank.
methodSchema - Schema for the request object
method - Name of the request method
responseSchema Schema for the response
responseClass The Apex class that the response will be unserialized into
}

此外,可以通过在 servicePort 类中创建对象来插入 Soap header 以及具有相同变量名+“_hns”的字符串,指定该对象的命名空间:

public SoapSecurity Security;
private String Security_hns = "Security=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";

apex XML 模式对象应包含每个子元素(或属性)的变量。变量名称与特定模式匹配的数组定义了对象变量在 xml 中的使用方式。

给出以下示例 XML:

<foo a="b"><bar>baz</bar></foo>

Apex 类将是这样的:

public class MyService {
public class bar {
public String bar;
private String[] bar_type_info = new String[] {'bar','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] apex_schema_type_info = new String[] {'http://schema.myservice.com', 'false', 'false'};
private String[] field_order_type_info = new String[] {'bar'};
}

public class foo {
public MyService.bar bar;
public String a;
private String[] bar_type_info = new String[] {'bar','http://schema.myservice.com','bar','0','1','true'};
private String[] a_att_info = new String[] {'a'};
private String apex_schema_type_info = new String[] {'http://schema.myservice.com','false','false'};
private String[] field_order_type_info = new String[] {'bar'};
}
}

以下是这些对象的(简要)分割:

如果变量表示另一个 XML 元素或文本节点,则需要有一个匹配的 _type_info String[],例如酒吧类型信息。该数组的元素是:1. XML元素名称2. 架构3.XML类型4.minOccurrs5. maxOccurs(设置为“-1”表示无界)6. isNillable

如果变量代表一个属性,那么必须有一个匹配的_att_info String[],例如a_type_info。 Thise 仅包含属性的 XML 名称。

请注意,如果类变量名称是保留字,则会在其后附加 _x,例如酒吧_x。这会影响其他变量名称:bar_x_type_info。 Apex 开发人员指南解释了他们的名称规则,但如果您手动创建它,我认为您可以给它任何您想要的名称 - 数组决定 XML 元素名称...

我还没有找到一种方法来表示还包含属性的简单 XML 类型:例如

<foo bar="baz">bar</foo>

apex_schema_type_info 数组指定有关该类表示的 XML 元素的信息:1. 架构2. 如果 elementFormDefault="qualified",则为“true”3. 如果 attributeFormDefault="qualified",则为“true”

我对 2 和 3 的实际作用仍然相当模糊,但它似乎会影响子元素(和属性)继承父命名空间的方式(无论是隐含的还是必须在生成的 XML 中指定)。

field_order_type_info 只是指定子元素的顺序。

请随时纠正或澄清...

关于api - Salesforce WebServiceCallout.invoke 方法的参数是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4392616/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com