以下是我迄今为止对 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 类中创建一个对象以及一个具有相同变量名称+“_hns”的字符串来插入 Soap 标头,该变量指定该对象的命名空间:
public SoapSecurity Security;
private String Security_hns = "Security=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
顶点 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[],例如 bar_type_info。该数组的元素是: 1. XML 元素名称 2. Schema 3. XML 类型 4. minOccurs 5. maxOccurs(设置为“-1”表示无界) 6. isNillable
如果变量代表一个属性,那么必须有一个匹配的_att_info String[] 例如a_type_info。Thise 仅包含属性的 XML 名称。
请注意,如果类变量名称是保留字,则将 _x 附加到其上,例如 bar_x。这会影响其他变量名称:bar_x_type_info。Apex 开发人员指南解释了他们的名称规则,但如果您手动创建它,我认为您可以给它任何您想要的名称——数组确定 XML 元素名称......
我还没有找到一种方法来表示还包含一个属性的简单 XML 类型:例如
<foo bar="baz">bar</foo>
apex_schema_type_info 数组指定类所表示的 XML 元素的相关信息: 1. Schema 2. 如果 elementFormDefault="qualified" 则为 'true' 3. 如果 attributeFormDefault="qualified" 则为'true'
对于 2 和 3 的实际作用,我仍然很模糊,但它似乎会影响子元素(和属性)如何继承父命名空间(无论是隐含的还是必须在生成的 XML 中指定)。
field_order_type_info 只是指定子元素的顺序。
请随时纠正或澄清...