2011-09-15 65 views
1

當我試圖從下面的WSDL文件,我收到 下生成的類(ES)生成的Apex類生成頂點類Salesforce的編譯錯誤具有編譯錯誤: 錯誤:testxyzCom 錯誤:意外的標記:'limit'at 7:23從WSDL

生成的類也在下面給出。我在Salesforce方面已經有一些經驗,並且據我記得,如果WSDL文檔包含Apex保留字,則在生成Apex類時,該字會附加_x。例如,WSDL文檔中的限制會在生成的Apex類中轉換爲limit_x。但是這不是在上面的情況下發生的請解釋。請幫助我。

WSDL文件

<?xml version="1.0" encoding="UTF-8"?> 
<wsdl:definitions targetNamespace="http://test.xyz.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://test.xyz.com" xmlns:intf="http://test.xyz.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
<!--WSDL created by Apache Axis version: 1.4 
Built on Apr 22, 2006 (06:55:48 PDT)--> 
<wsdl:types> 
<schema elementFormDefault="qualified" targetNamespace="http://test.xyz.com" xmlns="http://www.w3.org/2001/XMLSchema"> 
<element name="createOpurtunityData"> 
<complexType> 
<sequence> 
<element maxOccurs="unbounded" name="keys" type="xsd:string"/> 
<element maxOccurs="unbounded" name="values" type="xsd:string"/> 
<element name="limit" type="xsd:int"/> 
</sequence> 
</complexType> 
</element> 
<element name="createOpurtunityDataResponse"> 
<complexType> 
<sequence> 
<element maxOccurs="unbounded" name="createOpurtunityDataReturn" type="xsd:string"/> 
</sequence> 
</complexType> 
</element> 
</schema> 
</wsdl:types> 

<wsdl:message name="createOpurtunityDataResponse"> 

<wsdl:part element="impl:createOpurtunityDataResponse" name="parameters"> 

</wsdl:part> 

</wsdl:message> 

<wsdl:message name="createOpurtunityDataRequest"> 

<wsdl:part element="impl:createOpurtunityData" name="parameters"> 

</wsdl:part> 

</wsdl:message> 

<wsdl:portType name="TestWSDL"> 

<wsdl:operation name="createOpurtunityData"> 

<wsdl:input message="impl:createOpurtunityDataRequest" name="createOpurtunityDataRequest"> 

</wsdl:input> 

<wsdl:output message="impl:createOpurtunityDataResponse" name="createOpurtunityDataResponse"> 

</wsdl:output> 

</wsdl:operation> 

</wsdl:portType> 

<wsdl:binding name="TestWSDLSoapBinding" type="impl:TestWSDL"> 

<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 

<wsdl:operation name="createOpurtunityData"> 

<wsdlsoap:operation soapAction=""/> 

<wsdl:input name="createOpurtunityDataRequest"> 

<wsdlsoap:body use="literal"/> 

</wsdl:input> 

<wsdl:output name="createOpurtunityDataResponse"> 

<wsdlsoap:body use="literal"/> 

</wsdl:output> 

</wsdl:operation> 

</wsdl:binding> 

<wsdl:service name="TestWSDLService"> 

<wsdl:port binding="impl:TestWSDLSoapBinding" name="TestWSDL"> 

<wsdlsoap:address location="http://tempuri.org/Salesforcexyz/services/TestWSDL"/> 

</wsdl:port> 

</wsdl:service> 

</wsdl:definitions> 

生成的Apex類是

/Generated by wsdl2apex 

public class testxyzCom { 
public class createOpurtunityData_element { 
public String[] keys; 
public String[] values; 
public Integer limit; 
private String[] keys_type_info = new String[]{'keys','http://www.w3.org/2001/XMLSchema','string','1','-1','false'}; 
private String[] values_type_info = new String[]{'values','http://www.w3.org/2001/XMLSchema','string','1','-1','false'}; 
private String[] limit_type_info = new String[]{'limit','http://www.w3.org/2001/XMLSchema','int','1','1','false'}; 
private String[] apex_schema_type_info = new String[]{'http://test.xyz.com','true','false'}; 
private String[] field_order_type_info = new String[]{'keys','values','limit'}; 
} 
public class TestWSDL { 
public String endpoint_x = 'http://tempuri.org/Salesforcexyz/services/TestWSDL'; 
public Map<String,String> inputHttpHeaders_x; 
public Map<String,String> outputHttpHeaders_x; 
public String clientCertName_x; 
public String clientCert_x; 
public String clientCertPasswd_x; 
public Integer timeout_x; 
private String[] ns_map_type_info = new String[]{'http://test.xyz.com', 'testxyzCom'}; 
public String[] createOpurtunityData(String[] keys,String[] values,Integer limit) { 
testxyzCom.createOpurtunityData_element request_x = new testxyzCom.createOpurtunityData_element(); 
testxyzCom.createOpurtunityDataResponse_element response_x; 
request_x.keys = keys; 
request_x.values = values; 
request_x.limit = limit; 
Map<String, testxyzCom.createOpurtunityDataResponse_element> response_map_x = new Map<String, testxyzCom.createOpurtunityDataResponse_element>(); 
response_map_x.put('response_x', response_x); 
WebServiceCallout.invoke( 
this, 
request_x, 
response_map_x, 
new String[]{endpoint_x, 
'', 
'http://test.xyz.com', 
'createOpurtunityData', 
'http://test.xyz.com', 
'createOpurtunityDataResponse', 
'testxyzCom.createOpurtunityDataResponse_element'} 
); 
response_x = response_map_x.get('response_x'); 
return response_x.createOpurtunityDataReturn; 
} 
} 
public class createOpurtunityDataResponse_element { 
public String[] createOpurtunityDataReturn; 
private String[] createOpurtunityDataReturn_type_info = new String[]{'createOpurtunityDataReturn','http://www.w3.org/2001/XMLSchema','string','1','-1','false'}; 
private String[] apex_schema_type_info = new String[]{'http://test.xyz.com','true','false'}; 
private String[] field_order_type_info = new String[]{'createOpurtunityDataReturn'}; 
} 
} 

回答

0

我最近也有類似的問題,與使用保留關鍵字「產生的APEX類WSDL長'。

我不認爲wsdl2apex足夠聰明,可以根據您的建議爲保留關鍵字添加後綴。

你可以用手做到生成的類嗎?

在createOpurtunityData_element

public Integer limit_x; 

在TestWSDL

public String[] createOpurtunityData(String[] keys,String[] values,Integer limit_x) { 

request_x.limit_x = limit_x; 

我不是100%確定如何調用WebServiceCallout.invoke雖然會處理這種變化。如果可以的話,更新Web服務和WSDL以便它不使用APEX關鍵字會更容易。

+0

感謝您的建議。我已經通過將_x添加到保留關鍵字來手動生成頂點類。 :) –