You need to sign in to do that
Don't have an account?

Calling an external Webservice from VisualForce
Hi ,
I am trying to call an external web service from Visual force. I have taken a WSDL from http://strikeiron.com/ .This Web service provides DNS lookup information from a server name. I parsed the WSDL to the apex class and trying to call the request method in the Converted class from visual force. Visual force page Contains a button .On click ,it should display the dns name of Server passing('www.google.com') But whenever I am clicking on it .Getting an error:-"System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: No user identifier provided faultcode=soap:Client faultactor="
//Generated by wsdl2apex
public class tempuriOrg {
public class ArrayOfString {
public String[] string_x;
private String[] string_x_type_info = new String[]{'string','http://www.w3.org/2001/XMLSchema','string','0','-1','true'};
private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
private String[] field_order_type_info = new String[]{'string_x'};
}
public class DNSInfo {
public String HostName;
public tempuriOrg.ArrayOfString Aliases;
public tempuriOrg.ArrayOfString AddressList;
private String[] HostName_type_info = new String[]{'HostName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] Aliases_type_info = new String[]{'Aliases','http://tempuri.org/','ArrayOfString','0','1','false'};
private String[] AddressList_type_info = new String[]{'AddressList','http://tempuri.org/','ArrayOfString','0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
private String[] field_order_type_info = new String[]{'HostName','Aliases','AddressList'};
}
public class DNSLookupResponse_element {
public tempuriOrg.DNSInfo DNSLookupResult;
private String[] DNSLookupResult_type_info = new String[]{'DNSLookupResult','http://tempuri.org/','DNSInfo','0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
private String[] field_order_type_info = new String[]{'DNSLookupResult'};
}
public class DNSSoap {
public String endpoint_x = 'http://ws.strikeiron.com/relauto/iplookup/DNS';
public wsStrikeironCom.SubscriptionInfo SubscriptionInfo;
public wsStrikeironCom.LicenseInfo LicenseInfo;
private String SubscriptionInfo_hns = 'SubscriptionInfo=http://ws.strikeiron.com';
private String LicenseInfo_hns = 'LicenseInfo=http://ws.strikeiron.com';
private String[] ns_map_type_info = new String[]{'http://ws.strikeiron.com', 'wsStrikeironCom', 'http://tempuri.org/', 'tempuriOrg'};
public tempuriOrg.DNSInfo DNSLookup(String server) {
tempuriOrg.DNSLookup_element request_x = new tempuriOrg.DNSLookup_element();
tempuriOrg.DNSLookupResponse_element response_x;
request_x.server = server;
Map<String, tempuriOrg.DNSLookupResponse_element> response_map_x = new Map<String, tempuriOrg.DNSLookupResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://tempuri.org/DNSLookup',
'http://tempuri.org/',
'DNSLookup',
'http://tempuri.org/',
'DNSLookupResponse',
'tempuriOrg.DNSLookupResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.DNSLookupResult;
}
public void GetRemainingHits() {
wsStrikeironCom.GetRemainingHits_element request_x = new wsStrikeironCom.GetRemainingHits_element();
wsStrikeironCom.GetRemainingHitsResponse_element response_x;
Map<String, wsStrikeironCom.GetRemainingHitsResponse_element> response_map_x = new Map<String, wsStrikeironCom.GetRemainingHitsResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://ws.strikeiron.com/relauto/iplookup/DNS/GetRemainingHits',
'http://ws.strikeiron.com',
'GetRemainingHits',
'http://ws.strikeiron.com',
'GetRemainingHitsResponse',
'wsStrikeironCom.GetRemainingHitsResponse_element'}
);
response_x = response_map_x.get('response_x');
}
}
public class DNSLookup_element {
public String server;
private String[] server_type_info = new String[]{'server','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
private String[] field_order_type_info = new String[]{'server'};
}
}
It generated one more class wsStrikeironCom inside that I have given the userid and password inside a method called Which is
public class RegisteredUser {
public String UserID='rachana.raveendran@gmail.com';
public String Password='*******';
private String[] UserID_type_info = new String[]{UserID,'http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] Password_type_info = new String[]{Password,'http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] apex_schema_type_info = new String[]{'http://ws.strikeiron.com','true'};
private String[] field_order_type_info = new String[]{UserID,Password};
}
Here is my visual force code
public class Temperature
{
tempuriOrg.DNSInfo output;
public void recordReplicator()
{
tempuriOrg.DNSSoap stub = new tempuriOrg.DNSSoap(); String nserver='www.google.com'; System.debug('Server Ips'); output= stub.DNSLookup(nserver); System.Debug('output'+output); } public tempuriOrg.DNSInfo getOutput() { return output; } }
Remote site is created for http://ws.strikeiron.com
Please help me to solve this
Thanks
I am trying to call an external web service from Visual force. I have taken a WSDL from http://strikeiron.com/ .This Web service provides DNS lookup information from a server name. I parsed the WSDL to the apex class and trying to call the request method in the Converted class from visual force. Visual force page Contains a button .On click ,it should display the dns name of Server passing('www.google.com') But whenever I am clicking on it .Getting an error:-"System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: No user identifier provided faultcode=soap:Client faultactor="
//Generated by wsdl2apex
public class tempuriOrg {
public class ArrayOfString {
public String[] string_x;
private String[] string_x_type_info = new String[]{'string','http://www.w3.org/2001/XMLSchema','string','0','-1','true'};
private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
private String[] field_order_type_info = new String[]{'string_x'};
}
public class DNSInfo {
public String HostName;
public tempuriOrg.ArrayOfString Aliases;
public tempuriOrg.ArrayOfString AddressList;
private String[] HostName_type_info = new String[]{'HostName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] Aliases_type_info = new String[]{'Aliases','http://tempuri.org/','ArrayOfString','0','1','false'};
private String[] AddressList_type_info = new String[]{'AddressList','http://tempuri.org/','ArrayOfString','0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
private String[] field_order_type_info = new String[]{'HostName','Aliases','AddressList'};
}
public class DNSLookupResponse_element {
public tempuriOrg.DNSInfo DNSLookupResult;
private String[] DNSLookupResult_type_info = new String[]{'DNSLookupResult','http://tempuri.org/','DNSInfo','0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
private String[] field_order_type_info = new String[]{'DNSLookupResult'};
}
public class DNSSoap {
public String endpoint_x = 'http://ws.strikeiron.com/relauto/iplookup/DNS';
public wsStrikeironCom.SubscriptionInfo SubscriptionInfo;
public wsStrikeironCom.LicenseInfo LicenseInfo;
private String SubscriptionInfo_hns = 'SubscriptionInfo=http://ws.strikeiron.com';
private String LicenseInfo_hns = 'LicenseInfo=http://ws.strikeiron.com';
private String[] ns_map_type_info = new String[]{'http://ws.strikeiron.com', 'wsStrikeironCom', 'http://tempuri.org/', 'tempuriOrg'};
public tempuriOrg.DNSInfo DNSLookup(String server) {
tempuriOrg.DNSLookup_element request_x = new tempuriOrg.DNSLookup_element();
tempuriOrg.DNSLookupResponse_element response_x;
request_x.server = server;
Map<String, tempuriOrg.DNSLookupResponse_element> response_map_x = new Map<String, tempuriOrg.DNSLookupResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://tempuri.org/DNSLookup',
'http://tempuri.org/',
'DNSLookup',
'http://tempuri.org/',
'DNSLookupResponse',
'tempuriOrg.DNSLookupResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.DNSLookupResult;
}
public void GetRemainingHits() {
wsStrikeironCom.GetRemainingHits_element request_x = new wsStrikeironCom.GetRemainingHits_element();
wsStrikeironCom.GetRemainingHitsResponse_element response_x;
Map<String, wsStrikeironCom.GetRemainingHitsResponse_element> response_map_x = new Map<String, wsStrikeironCom.GetRemainingHitsResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://ws.strikeiron.com/relauto/iplookup/DNS/GetRemainingHits',
'http://ws.strikeiron.com',
'GetRemainingHits',
'http://ws.strikeiron.com',
'GetRemainingHitsResponse',
'wsStrikeironCom.GetRemainingHitsResponse_element'}
);
response_x = response_map_x.get('response_x');
}
}
public class DNSLookup_element {
public String server;
private String[] server_type_info = new String[]{'server','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true'};
private String[] field_order_type_info = new String[]{'server'};
}
}
It generated one more class wsStrikeironCom inside that I have given the userid and password inside a method called Which is
public class RegisteredUser {
public String UserID='rachana.raveendran@gmail.com';
public String Password='*******';
private String[] UserID_type_info = new String[]{UserID,'http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] Password_type_info = new String[]{Password,'http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] apex_schema_type_info = new String[]{'http://ws.strikeiron.com','true'};
private String[] field_order_type_info = new String[]{UserID,Password};
}
Here is my visual force code
public class Temperature
{
tempuriOrg.DNSInfo output;
public void recordReplicator()
{
tempuriOrg.DNSSoap stub = new tempuriOrg.DNSSoap(); String nserver='www.google.com'; System.debug('Server Ips'); output= stub.DNSLookup(nserver); System.Debug('output'+output); } public tempuriOrg.DNSInfo getOutput() { return output; } }
Remote site is created for http://ws.strikeiron.com
Please help me to solve this
Thanks
tempuriOrg.DNSSoap stub = new tempuriOrg.DNSSoap();
stub.SubscriptionInfo = new wsStrikeironCom.SubscriptionInfo();
//set the email, password etc on SubscriptionInfo.
//stub.SubscriptionInfo
Then call the external service method.
Thanks for your response.
public class SubscriptionInfo {But i didn’t find any variables in SubscriptionInfo to set the email, password etc on SubscriptionInfo.
This is the generated SubscriptionInfo class
public Integer LicenseStatusCode;
public String LicenseStatus;
public Integer LicenseActionCode;
public String LicenseAction;
public Integer RemainingHits;
public Double Amount;
private String[] LicenseStatusCode_type_info = new String[]{'LicenseStatusCode','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
private String[] LicenseStatus_type_info = new String[]{'LicenseStatus','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] LicenseActionCode_type_info = new String[]{'LicenseActionCode','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
private String[] LicenseAction_type_info = new String[]{'LicenseAction','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] RemainingHits_type_info = new String[]{'RemainingHits','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
private String[] Amount_type_info = new String[]{'Amount','http://www.w3.org/2001/XMLSchema','decimal','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://ws.strikeiron.com','true'};
private String[] field_order_type_info = new String[]{'LicenseStatusCode','LicenseStatus','LicenseActionCode','LicenseAction','RemainingHits','Amount'};
}
Can u please suggest a method to set this?
Another class called Registered user is there
public class RegisteredUser {
public String UserID='rachana.raveendran@gmail.com';
public String Password='***********';
private String[] UserID_type_info = new String[]{UserID,'http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] Password_type_info = new String[]{Password,'http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] apex_schema_type_info = new String[]{'http://ws.strikeiron.com','true'};
private String[] field_order_type_info = new String[]{UserID,Password};
}
Here i have given the email(userid) and password.
tempuriOrg.DNSSoap stub = new tempuriOrg.DNSSoap();
stub.LicenseInfo = new wsStrikeironCom.LicenseInfo();
stub.LicenseInfo.RegisteredUser = new wsStrikeironCom.RegisteredUser();
stub.LicenseInfo.RegisteredUser.UserId = 'your user id';
stub.LicenseInfo.RegisteredUser.Password = 'your password';
//stub.DNSLookup
I changed the visual force code like this
public class Temperature123
{
tempuriOrg.DNSInfo output;
public pagereference recordReplicator()
{
tempuriOrg.DNSSoap stub = new tempuriOrg.DNSSoap();
stub.LicenseInfo = new wsStrikeironCom.LicenseInfo();
stub.LicenseInfo.RegisteredUser = new wsStrikeironCom.RegisteredUser();
stub.LicenseInfo.RegisteredUser.UserID ='rachana.raveendran@gmail.com';
stub.LicenseInfo.RegisteredUser.Password ='**********';
String nserver='www.google.com';
System.debug('Server Ips');
output= stub.DNSLookup(nserver);
System.Debug('output'+output);
return page.first_visual_force_page;
}
public tempuriOrg.DNSInfo getoutput()
{
return output;
}
}
But now i am getting an error like
System.CalloutException: Web service callout failed: Unable to find field 'null' found in fieldOrder
Sourcecode:
If you download this from the AppExchange: http://www.salesforce.com/appexchange/detail_overview.jsp?NavCode__c=&id=a0330000004ZjewAAC
it's free to download and try, and it has the source code available for consuming StrikeIron Web services within Apex. That might help you here. The code would probably be the same for consuming other Web services as well, and the download is a complete certified add-on that enables demographic data to be consumed as a Web service, and then added to a contact record so you have better information to sell with. The code is there and it works.
If you register with StrikeIron you will get 25 free trial hits for every Web service - so register at the site before you try to run any code (it's free). They also provide two sets of WSDLs for each Web service, one that utilizes SOAP Headers, one that doesn't. SOAP Headers are the best way to keep data payloads separate, however they can be more difficult to implement.
If you want to bypass any services that require passwords and just get a few of them running, they also have several free Web services that don't require any authentication:
http://www.strikeiron.com/Marketplace/liteservices.aspx
The AppExchange URL mentioned in this thread for the StrikeIron example is no longer valid. Can anyone recommend another cdoe example for calling a web service?