function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Raghu_devRaghu_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

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;
 }

 

Raghu_devRaghu_dev
Can someone help me on this PLEASE .
SuperfellSuperfell
What's the response XML look like, and have you validated that against the WSDL ?
Raghu_devRaghu_dev
Hi Simon,

Thanks for the response. Where can I see the response xml ? I did execute the class method from the system log window but couldnt find the xml in the log output even after setting the debug level as callout. Also, I tried using the system.debug method to output the xml but no luck. As a last option I installed Soapscope (a tool from mindreef) to see the output, but I am not sure how to compare the wsdl from xml using that tool. Please let me know if there is a simple way to do this comparision.

Thanks
Raghu_devRaghu_dev
Here is the response xml :

Code:
<?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>
</ServiceResult>
</CompanySearchResult>
</CompanySearchResponse>
</soap:Body>
</soap:Envelope>

 


Message Edited by Raghu_dev on 08-26-2008 11:56 AM
SuperfellSuperfell
Where's the WDSL? does it define the serviceStatus element ?
Raghu_devRaghu_dev
Here is the link to the wsdl

http://ws.strikeiron.com/DnBBusinessProspect2?WSDL

It does have a element for ServiceStatus.

Thanks
Raghu