You need to sign in to do that
Don't have an account?
Raghu_dev
Apex to external Web Service communication - Failing during parsing
Hi,
I am having problem when accessing strikeiron webservice. Please help me.
I am accessing strikeiron webservice and trying to show the output in a scontrol but I am getting an error saying
System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element http://www.strikeiron.com=ServiceStatus
I am having problem when accessing strikeiron webservice. Please help me.
I am accessing strikeiron webservice and trying to show the output in a scontrol but I am getting an error saying
System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element http://www.strikeiron.com=ServiceStatus
Code:
// Here is the scontrol code // <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <script type="text/javascript" src="/js/functions.js"></script> <script src="/soap/ajax/12.0/connection.js"></script> <script src="/soap/ajax/12.0/apex.js"></script> </head> <body> <div class="pagelabel"> Call webservice</div> <script language="javascript" type="text/javascript"> function callStrikeIron() { //alert("Call Strike"); var elem = document.getElementById("docBody"); sforce.apex.debug=true; var theBody = '<table><tr><td>ZipInfo</td><td>'; var result = sforce.apex.execute("StrikeIronWrapper", "wrapper", {varZipCode:"19406"}); theBody += result + '</td></tr></table>'; elem.innerHTML = theBody; } callStrikeIron(); </script> <div id="docBody"></div> </body> </html> // Here is the actual class //Generated by wsdl2apex global class zipInfoLookup{ public class ZipInfoListing { public String CityName; public String PreferredName; public String StateAbbreviation; public String Classification; public String County; private String[] CityName_type_info = new String[]{'CityName','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] PreferredName_type_info = new String[]{'PreferredName','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] StateAbbreviation_type_info = new String[]{'StateAbbreviation','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] Classification_type_info = new String[]{'Classification','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] County_type_info = new String[]{'County','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'CityName','PreferredName','StateAbbreviation','Classification','County'}; } public class ServiceOutput { public zipInfoLookup.SIWsStatus ServiceStatus; private String[] ServiceStatus_type_info = new String[]{'ServiceStatus','http://www.strikeiron.com','SIWsStatus','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'ServiceStatus'}; } public class ZipInfoResult { public String Code; public String Latitude; public String Longitude; public String TimeZone; public String StandardGMTOffset; public String DaylightGMTOffset; public zipInfoLookup.ArrayOfZipInfoListing Listings; private String[] Code_type_info = new String[]{'Code','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] Latitude_type_info = new String[]{'Latitude','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] Longitude_type_info = new String[]{'Longitude','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] TimeZone_type_info = new String[]{'TimeZone','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] StandardGMTOffset_type_info = new String[]{'StandardGMTOffset','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] DaylightGMTOffset_type_info = new String[]{'DaylightGMTOffset','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] Listings_type_info = new String[]{'Listings','http://www.strikeiron.com','ArrayOfZipInfoListing','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'Code','Latitude','Longitude','TimeZone','StandardGMTOffset','DaylightGMTOffset','Listings'}; } public class ServiceInfoRecord { public String InfoKey; public String InfoValue; private String[] InfoKey_type_info = new String[]{'InfoKey','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] InfoValue_type_info = new String[]{'InfoValue','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'InfoKey','InfoValue'}; } public class zipinfoSoap { public String endpoint_x = 'http://ws.strikeiron.com/StrikeIron/ZipInfo3/zipinfo'; public Map<String,String> inputHttpHeaders_x; public Map<String,String> outputHttpHeaders_x; public String clientCert_x; public String clientCertPasswd_x; 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://www.strikeiron.com', 'zipInfoLookup'}; 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/StrikeIron/ZipInfo3/zipinfo/GetRemainingHits', 'http://ws.strikeiron.com', 'GetRemainingHits', 'http://ws.strikeiron.com', 'GetRemainingHitsResponse', 'wsStrikeironCom.GetRemainingHitsResponse_element'} ); response_x = response_map_x.get('response_x'); } public zipInfoLookup.StatusCodeOutput GetAllStatuses() { zipInfoLookup.GetAllStatuses_element request_x = new zipInfoLookup.GetAllStatuses_element(); zipInfoLookup.GetAllStatusesResponse_element response_x; Map<String, zipInfoLookup.GetAllStatusesResponse_element> response_map_x = new Map<String, zipInfoLookup.GetAllStatusesResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://www.strikeiron.com/GetAllStatuses', 'http://www.strikeiron.com', 'GetAllStatuses', 'http://www.strikeiron.com', 'GetAllStatusesResponse', 'zipInfoLookup.GetAllStatusesResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.GetAllStatusesResult; } public zipInfoLookup.ServiceInfoOutput GetServiceInfo() { zipInfoLookup.GetServiceInfo_element request_x = new zipInfoLookup.GetServiceInfo_element(); zipInfoLookup.GetServiceInfoResponse_element response_x; Map<String, zipInfoLookup.GetServiceInfoResponse_element> response_map_x = new Map<String, zipInfoLookup.GetServiceInfoResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://www.strikeiron.com/GetServiceInfo', 'http://www.strikeiron.com', 'GetServiceInfo', 'http://www.strikeiron.com', 'GetServiceInfoResponse', 'zipInfoLookup.GetServiceInfoResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.GetServiceInfoResult; } public zipInfoLookup.ZipInfoOutput GetCityState(String ZipCode) { // zipInfoLookup.ZipInfoOutput zipInfoLookup.GetCityState_element request_x = new zipInfoLookup.GetCityState_element(); zipInfoLookup.GetCityStateResponse_element response_x; request_x.ZipCode = ZipCode; Map<String, zipInfoLookup.GetCityStateResponse_element> response_map_x = new Map<String, zipInfoLookup.GetCityStateResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://www.strikeiron.com/GetCityState', 'http://www.strikeiron.com', 'GetCityState', 'http://www.strikeiron.com', 'GetCityStateResponse', 'zipInfoLookup.GetCityStateResponse_element'} ); response_x = response_map_x.get('response_x'); system.debug('response ' + response_x); return response_x.GetCityStateResult; } } public class GetServiceInfo_element { private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{}; } public class SIWsStatus { public Integer StatusNbr; public String StatusDescription; private String[] StatusNbr_type_info = new String[]{'StatusNbr','http://www.w3.org/2001/XMLSchema','int','1','1','false'}; private String[] StatusDescription_type_info = new String[]{'StatusDescription','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'StatusNbr','StatusDescription'}; } public class ArrayOfZipInfoListing { public zipInfoLookup.ZipInfoListing[] ZipInfoListing; private String[] ZipInfoListing_type_info = new String[]{'ZipInfoListing','http://www.strikeiron.com','ZipInfoListing','0','-1','true'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'ZipInfoListing'}; } public class StatusCodeOutput { public zipInfoLookup.StatusCodeResult ServiceResult; private String[] ServiceResult_type_info = new String[]{'ServiceResult','http://www.strikeiron.com','StatusCodeResult','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'ServiceResult'}; } public class ArrayOfSIWsStatus { public zipInfoLookup.SIWsStatus[] SIWsStatus; private String[] SIWsStatus_type_info = new String[]{'SIWsStatus','http://www.strikeiron.com','SIWsStatus','0','-1','true'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'SIWsStatus'}; } global class ZipInfoOutput { public zipInfoLookup.ZipInfoResult ServiceResult; private String[] ServiceResult_type_info = new String[]{'ServiceResult','http://www.strikeiron.com','ZipInfoResult','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'ServiceResult'}; } public class SIWsResult { public Integer Count; private String[] Count_type_info = new String[]{'Count','http://www.w3.org/2001/XMLSchema','int','1','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'Count'}; } public class GetCityState_element { public String ZipCode; private String[] ZipCode_type_info = new String[]{'ZipCode','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'ZipCode'}; } public class StatusCodeResult { public zipInfoLookup.ArrayOfSIWsStatus Statuses; private String[] Statuses_type_info = new String[]{'Statuses','http://www.strikeiron.com','ArrayOfSIWsStatus','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'Statuses'}; } public class SIServiceInfoResult { public zipInfoLookup.ArrayOfServiceInfoRecord ServiceInfo; private String[] ServiceInfo_type_info = new String[]{'ServiceInfo','http://www.strikeiron.com','ArrayOfServiceInfoRecord','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'ServiceInfo'}; } public class ArrayOfServiceInfoRecord { public zipInfoLookup.ServiceInfoRecord[] ServiceInfoRecord; private String[] ServiceInfoRecord_type_info = new String[]{'ServiceInfoRecord','http://www.strikeiron.com','ServiceInfoRecord','0','-1','true'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'ServiceInfoRecord'}; } public class GetAllStatuses_element { private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{}; } public class GetServiceInfoResponse_element { public zipInfoLookup.ServiceInfoOutput GetServiceInfoResult; private String[] GetServiceInfoResult_type_info = new String[]{'GetServiceInfoResult','http://www.strikeiron.com','ServiceInfoOutput','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'GetServiceInfoResult'}; } public class GetCityStateResponse_element { public zipInfoLookup.ZipInfoOutput GetCityStateResult; private String[] GetCityStateResult_type_info = new String[]{'GetCityStateResult','http://www.strikeiron.com','ZipInfoOutput','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'GetCityStateResult'}; } public class GetAllStatusesResponse_element { public zipInfoLookup.StatusCodeOutput GetAllStatusesResult; private String[] GetAllStatusesResult_type_info = new String[]{'GetAllStatusesResult','http://www.strikeiron.com','StatusCodeOutput','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'GetAllStatusesResult'}; } public class ServiceInfoOutput { public zipInfoLookup.SIServiceInfoResult ServiceResult; private String[] ServiceResult_type_info = new String[]{'ServiceResult','http://www.strikeiron.com','SIServiceInfoResult','0','1','false'}; private String[] apex_schema_type_info = new String[]{'http://www.strikeiron.com','true'}; private String[] field_order_type_info = new String[]{'ServiceResult'}; } } // Here is the wrapper global class StrikeIronWrapper { webservice static zipInfoLookup.ZipInfoOutput wrapper(string varZipCode){ //zipInfoLookup zipInfoLookupCls = new zipInfoLookup(); zipInfoLookup.zipinfoSoap zip = new zipInfoLookup.zipinfoSoap(); zip.LicenseInfo = new wsStrikeironCom.LicenseInfo(); zip.LicenseInfo.RegisteredUser = new wsStrikeironCom.RegisteredUser(); zip.LicenseInfo.RegisteredUser.UserID = 'test@test.com'; zip.LicenseInfo.RegisteredUser.Password = 'test'; //zipInfoLookup.ZipInfoOutput zipinfo = zip.GetCityState('06010'); zipInfoLookup.ZipInfoOutput zipinfo = zip.GetCityState(varZipCode); return zipinfo; } }
http://ws.strikeiron.com/DnBBusinessProspect2?WSDL
Thanks for your response.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Header xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<SubscriptionInfo xmlns="http://ws.strikeiron.com">
<LicenseStatusCode>0</LicenseStatusCode>
<LicenseStatus>Valid license key</LicenseStatus>
<LicenseActionCode>7</LicenseActionCode>
<LicenseAction>No hit deduction for invocation</LicenseAction>
<RemainingHits>25</RemainingHits>
<Amount>0</Amount>
</SubscriptionInfo>
</Header>
<soap:Body>
<CompanySearchResponse xmlns="http://www.strikeiron.com">
<CompanySearchResult>
<ServiceStatus>
<StatusNbr>213</StatusNbr>
<StatusDescription>Successful search</StatusDescription>
</ServiceStatus>
<ServiceResult>
<Count>1</Count>
<CandidateCompanies>
<CandidateCompany>
<CompanyName>US TEST COMPANY 197</CompanyName>
<StreetAddress>899 EATON AVE</StreetAddress>
<City>BETHLEHEM</City>
<State>PA</State>
<PostalCode>180251000</PostalCode>
<Phone>6108820001</Phone>
<CountryCode>US</CountryCode>
<BranchIndicator>Single location</BranchIndicator>
<TradingName />
<ConfidenceCode>10</ConfidenceCode>
<MatchGrade>AAAAAZZ</MatchGrade>
<MatchNameGrade>Same</MatchNameGrade>
<MatchNamePercent>100</MatchNamePercent>
<MatchStreetNumberGrade>Same</MatchStreetNumberGrade>
<MatchStreetNumberPercent>100</MatchStreetNumberPercent>
<MatchStreetNameGrade>Same</MatchStreetNameGrade>
<MatchStreetNamePercent>100</MatchStreetNamePercent>
<MatchCityGrade>Same</MatchCityGrade>
<MatchCityPercent>100</MatchCityPercent>
<MatchCountryStateGrade>Same</MatchCountryStateGrade>
<MatchCountryStatePercent>100</MatchCountryStatePercent>
<MatchPOBoxGrade>Not provided</MatchPOBoxGrade>
<MatchPOBoxPercent>-1</MatchPOBoxPercent>
<MatchPhoneGrade>Not provided</MatchPhoneGrade>
<MatchPhonePercent>-1</MatchPhonePercent>
</CandidateCompany>
</CandidateCompanies>
CompanySearchResult is of type SearchOutput:
<s:element minOccurs="0" maxOccurs="1" name="CompanySearchResult" type="si:SearchOutput"/>
SearchOutput is an extension of SIWsOutput:
<s:complexType name="SearchOutput">
<s:complexContent mixed="false">
<s:extension base="si:SIWsOutput">
This is not supported. If you pull the extension elements to the child object. That is change SearchOutput to :
<s:complexType name="SearchOutput">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ServiceStatus" type="si:SIWsStatus"/>
<s:element minOccurs="0" maxOccurs="1" name="ServiceResult" type="si:SearchResult"/>
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
This may work.
HTHs,
That error is not coming up again after making the change as suggested by you, but other similar errors ( i believe there are several extensions which are complex types out there in the wsdl) are now popping up.
Couple of questions :
1. Currently I am modifying the wsdl on my local pc but the actual wsdl that was published by strikeiron is not editable. Would that be a problem if I make the change to the wsdl to generate the class file and the actual response wouldnt be in the same format ?
2. Would it be resolved by salesforce at some point of time (callouts handling complex type extensions?)
Please suggest.
1. you are only pulling down based elements to child. On the wire XML will not change.
2. Not in the short term
Message Edited by tim-at-hastings on 01-01-2009 07:50 AM