You need to sign in to do that
Don't have an account?
Gaurish Gopal Goel
Generating Apex Class from WSDL
I have a WSDL for some currency convertor application. I am trying to generate an apex class from wsdl.
When i tried to upload the wsdl, some errors came like Multiple Porttype, Multiple binding etc. After editing this wsdl somehow i fixed those errors and successfully parsed the wsdl.
But at the final step an error is occuring saying that: APEX GENERATION FAILED. UNABLE TO FIND SOAP 1.1 ADDRESS.
Please give some tips I am new to web services.
Did not understand the logic behind it, but worked fine when i downloaded the WSDL file through IE.
Regards,
Satish Kumar
All Answers
Did not understand the logic behind it, but worked fine when i downloaded the WSDL file through IE.
Regards,
Satish Kumar
Hello,
Apex class can be generated from the Soap 1.1 services, seems your WSDL contains only soap 1.2 services and that is why its failing. You will need WSDL which uses soap 1.1 service.
Use only SOAP, refer example:
http://stackoverflow.com/questions/7189134/wcf-basichttpbinding-where-can-i-find-soap1-1-in-wsdl
Thanks SATISH for the solution. Thanks Vinita for the contribution. Satish's solution worked absolutely fine for me.
Hi,
I found what the problem is!!
You are using a multiple portType for WSDL and it is not supported. Because, portType shows for getting in/out messages at a single port.
Anyways, I deleted other all the portypes and kept only one portType name="CurrencyConvertorSoap", and i completed parsing the wsdl without any errors and it has generated a class as well.
Am attaching the generated class as well as WSDL file i used to generate the class. Please find it as shown below.
WSDL:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://www.webserviceX.NET/" xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="http://www.webserviceX.NET/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.webserviceX.NET/">
<s:element name="ConversionRate">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="FromCurrency" type="tns:Currency" />
<s:element minOccurs="1" maxOccurs="1" name="ToCurrency" type="tns:Currency" />
</s:sequence>
</s:complexType>
</s:element>
<s:simpleType name="Currency">
</s:simpleType>
<s:element name="ConversionRateResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="ConversionRateResult" type="s:double" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="double" type="s:double" />
</s:schema>
</wsdl:types>
<wsdl:message name="ConversionRateSoapIn">
<wsdl:part name="parameters" element="tns:ConversionRate" />
</wsdl:message>
<wsdl:message name="ConversionRateSoapOut">
<wsdl:part name="parameters" element="tns:ConversionRateResponse" />
</wsdl:message>
<wsdl:portType name="CurrencyConvertorSoap">
<wsdl:operation name="ConversionRate">
<wsdl:input message="tns:ConversionRateSoapIn" />
<wsdl:output message="tns:ConversionRateSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CurrencyConvertorSoap" type="tns:CurrencyConvertorSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="ConversionRate">
<soap:operation soapAction="http://www.webserviceX.NET/ConversionRate" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CurrencyConvertor">
<wsdl:port name="CurrencyConvertorSoap" binding="tns:CurrencyConvertorSoap">
<soap:address location="http://www.webservicex.net/CurrencyConvertor.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Generated class:
//Generated by wsdl2apex
public class wwwWebservicexNet {
public class CurrencyConvertorSoap {
public String endpoint_x = 'http://www.webservicex.net/CurrencyConvertor.asmx';
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://www.webserviceX.NET/', 'wwwWebservicexNet'};
public Double ConversionRate(String FromCurrency,String ToCurrency) {
wwwWebservicexNet.ConversionRate_element request_x = new wwwWebservicexNet.ConversionRate_element();
wwwWebservicexNet.ConversionRateResponse_element response_x;
request_x.FromCurrency = FromCurrency;
request_x.ToCurrency = ToCurrency;
Map<String, wwwWebservicexNet.ConversionRateResponse_element> response_map_x = new Map<String, wwwWebservicexNet.ConversionRateResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://www.webserviceX.NET/ConversionRate',
'http://www.webserviceX.NET/',
'ConversionRate',
'http://www.webserviceX.NET/',
'ConversionRateResponse',
'wwwWebservicexNet.ConversionRateResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.ConversionRateResult;
}
}
public class ConversionRate_element {
public String FromCurrency;
public String ToCurrency;
private String[] FromCurrency_type_info = new String[]{'FromCurrency','http://www.webserviceX.NET/',null,'1','1','false'};
private String[] ToCurrency_type_info = new String[]{'ToCurrency','http://www.webserviceX.NET/',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://www.webserviceX.NET/','true','false'};
private String[] field_order_type_info = new String[]{'FromCurrency','ToCurrency'};
}
public class ConversionRateResponse_element {
public Double ConversionRateResult;
private String[] ConversionRateResult_type_info = new String[]{'ConversionRateResult','http://www.webserviceX.NET/',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://www.webserviceX.NET/','true','false'};
private String[] field_order_type_info = new String[]{'ConversionRateResult'};
}
}
Hope so this helps you...!
Please mark this answer a Solution and please give kudos by clicking on the star icon, if you found this answer as helpful.
I appreciate your help as well. Thanks again.
Good to see your reply. Thank you.
the apex as well. :-)
looking forward for more help from you in future.
--
With Regards
Gaurish Gopal Goel
Sure, thanks again.
Now i am trying to call this Apex Class in Developer console.
it is giving error like, "Illegal assignment from Double to String"
I am stuck here, any help would be appreciated.
Regards,
Pragnesh Karia
wwwWebservicexNetCurrency.CurrencyConvertorSoap proxyClass = new wwwWebservicexNetCurrency.CurrencyConvertorSoap();
Double retVal = proxyClass.ConversionRate('INR','USD'); //Replace string with Double.
System.debug(retVal);