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
Jason Gelsomino 9Jason Gelsomino 9 

Webservice Call to external system using APEX

Hello, 

I am trying to create a webservice call to an external system using APEX. I went and created the class from the WSDL using Fuse It. Then I created the VF page where I added a simple text input field and a output field for the response. I am having difficulty writing the controller to make this all work. 

Here is the code I have thus far:

VF Page
<apex:page controller="WebserviceCall">
  <apex:form >
     <apex:pageBlock >
         <apex:commandButton action="[!hello}" value="Initiate Webservice Call"/> <br/><br/>
         Drug Name: <apex:inputText value="{!ListProductNames}"/> <br/><br/>
         
         Product Name Output -- <apex:outputText value="{!ListProductNames}"/>
     </apex:pageBlock> 
  </apex:form>
</apex:page>
Controller
public with sharing class WebserviceCall {

    public String ListProductNames { get; set; }

   public String productName { get; set; }
 public Double message {get; private set;}

  public PageReference hello() {    
    gsddGoldstandardCom.ListProductNames  stub = new       gsddGoldstandardCom.ListProductNames();
    message = stub.ListProductNames(productName );
        return null;
    }

}

Class generated by Fuse IT
 
public gsddGoldstandardCom.ListProductNames_element ListProductNames(String NameFilter,Integer MaxResultsReturned) {
			gsddGoldstandardCom.ListProductNamesRequest_element request_x = new gsddGoldstandardCom.ListProductNamesRequest_element();
			gsddGoldstandardCom.ListProductNames_element response_x;
			request_x.NameFilter = NameFilter;
			request_x.MaxResultsReturned = MaxResultsReturned;
			Map<String, gsddGoldstandardCom.ListProductNames_element> response_map_x = new Map<String, gsddGoldstandardCom.ListProductNames_element>();
			response_map_x.put('response_x', response_x);
			WebServiceCallout.invoke(
				this,
				request_x,
				response_map_x,
				new String[]{endpoint_x,
				'urn:ListProductNames',
				'http://gsdd.goldstandard.com/',
				'ListProductNamesRequest',
				'http://gsdd.goldstandard.com/',
				'ListProductNames',
				'gsddGoldstandardCom.ListProductNames_element'}
			);
			response_x = response_map_x.get('response_x');
			return response_x;
		}

Any thoughts would be appreciated!!!!

Thanks
 
LBKLBK
Hi Jason,

Can you publish your Web service class (full code) that you have generated from WSDL file?

This will help in understanding the response type of the Web service call.

In first look your web method seems to be returning a type gsddGoldstandardCom.ListProductNames_element, but you are assigning it to a Double.
LBKLBK
If you have WSDL URL of your sample web service, post that. We can always generate the APEX Proxy class by importing the WSDL file.
Jason Gelsomino 9Jason Gelsomino 9
The WSDL is sitting on my local machine.
Jason Gelsomino 9Jason Gelsomino 9
Is there a way to attached the WSDL or send it to you directly? I'm still getting the 503 maintenance error.....sorry about that.
Jason Gelsomino 9Jason Gelsomino 9
Try this....
public class gsddGoldstandardCom {
	public class ListProductNames_element {
		public String NameFilter;
		public gsddGoldstandardCom.ProductIdentifierNameMarketerType[] Product;
		private String[] NameFilter_type_info = new String[]{'NameFilter','http://gsdd.goldstandard.com/','string','0','1','true'};
		private String[] Product_type_info = new String[]{'Product','http://gsdd.goldstandard.com/','ProductIdentifierNameMarketerType','0','-1','false'};
		private String[] apex_schema_type_info = new String[]{'http://gsdd.goldstandard.com/','true','false'};
		private String[] field_order_type_info = new String[]{'NameFilter','Product'};
	}