13

SalesforceがリモートWebサービスを呼び出すために使用するinvokeメソッドのパラメータを知りたいのですが。呼び出すことができると思われるサービスがありますが、サービスWSDLはセキュリティ要件を定義していないため、その情報を手動で追加できることを望んでいます(サービスはSoapヘッダーを介して渡される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
);

誰かがギャップを埋めるのを手伝ってもらえますか?

4

2 に答える 2

24

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
}

さらに、soapヘッダーは、servicePortクラスにオブジェクトを作成するとともに、そのオブジェクトの名前空間を指定する同じ変数名+"_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 [](bar_type_infoなど)が必要です。この配列の要素は次のとおりです。1。XML要素名2.スキーマ3.XMLタイプ4.minOccurs5. maxOccurs(無制限の場合は「-1」に設定)6。isNillable

変数が属性を表す場合は、一致する_att_info String []、たとえばa_type_infoが存在する必要があります。これには、属性のXML名が含まれているだけです。

クラス変数名が予約語の場合、_xがそれに追加されることに注意してください(例:bar_x)。これは他の変数名に影響します:bar_x_type_info。Apex開発者ガイドでは名前の規則について説明していますが、手動で作成する場合は、任意の名前を付けることができると思います。配列によってXML要素の名前が決まります...

属性も含む単純なXML型を表す方法が見つかりませんでした。例:

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

apex_schema_type_info配列は、クラスによって表されるXML要素に関する情報を指定します。1。スキーマ2.'true' if elementFormDefault = "qualified" 3.'true' if attributeFormDefault = "qualified"

2と3が実際に何をするかについてはまだかなりあいまいですが、子要素(および属性)が親名前空間を継承する方法に影響を与えるようです(暗黙的であるか、結果のXMLで指定する必要があるかどうか)。

field_order_type_infoは、子要素の順序を指定するだけです。

お気軽に訂正または明確にしてください...

于 2010-12-16T17:45:58.743 に答える
7

Force.com Apexコード開発者ガイド-生成されたコードを理解するがありますが、現在、の詳細についてはかなりまばらですWebServiceCallout.invoke(...)

Apex Webサービスとコールアウトもありますが、これも有用な詳細ではありません。

賛成票のアイデア:WebServiceCalloutのドキュメントは、長期的には役立つ可能性があります。


SalesforceはGithubでwsdl2apexのオープンソースリリースを行ったばかりなので、コードをチェックして何が起こっているのかを正確に確認できます。オープンソースのWSDL2Apexジェネレーターの発表

于 2011-04-08T00:56:15.610 に答える