You need to sign in to do that
Don't have an account?
hylim
public class AxisWS {
public class sayhello_element {
public String Input;
private String[] Input_type_info = new String[]{'Input','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://webapp.wtp','true','false'};
private String[] field_order_type_info = new String[]{'Input'};
}
public class HelloWord {
public String endpoint_x = 'http://192.168.0.10:8080/AxisWS/services/HelloWord';
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://webapp.wtp', 'AxisWS'};
public String sayhello(String Input) {
AxisWS.sayhello_element request_x = new AxisWS.sayhello_element();
AxisWS.sayhelloResponse_element response_x;
request_x.Input = Input;
Map<String, AxisWS.sayhelloResponse_element> response_map_x = new Map<String, AxisWS.sayhelloResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://webapp.wtp',
'sayhello',
'http://webapp.wtp',
'sayhelloResponse',
'AxisWS.sayhelloResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.sayhelloReturn;
}
}
public class sayhelloResponse_element {
public String sayhelloReturn;
private String[] sayhelloReturn_type_info = new String[]{'sayhelloReturn','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://webapp.wtp','true','false'};
private String[] field_order_type_info = new String[]{'sayhelloReturn'};
}
}
public WSContoller(ApexPages.StandardController controller) {
}
public String getHelloName() {
string MyReturn;
AxisWS.HelloWord stub = new AxisWS.HelloWord();
MyReturn = stub.sayhello('lhy');
return MyReturn ;
}
}
Error Calling External WebService "Parser was expecting element"
Hi i need some help for my callout webservice.
I have created a simple webservice which pass in a string and return "Hello 'strng'" from eclipse IDE and below is the generated apex code from WSDL
//Generated by wsdl2apex
public class AxisWS {
public class sayhello_element {
public String Input;
private String[] Input_type_info = new String[]{'Input','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://webapp.wtp','true','false'};
private String[] field_order_type_info = new String[]{'Input'};
}
public class HelloWord {
public String endpoint_x = 'http://192.168.0.10:8080/AxisWS/services/HelloWord';
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://webapp.wtp', 'AxisWS'};
public String sayhello(String Input) {
AxisWS.sayhello_element request_x = new AxisWS.sayhello_element();
AxisWS.sayhelloResponse_element response_x;
request_x.Input = Input;
Map<String, AxisWS.sayhelloResponse_element> response_map_x = new Map<String, AxisWS.sayhelloResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://webapp.wtp',
'sayhello',
'http://webapp.wtp',
'sayhelloResponse',
'AxisWS.sayhelloResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.sayhelloReturn;
}
}
public class sayhelloResponse_element {
public String sayhelloReturn;
private String[] sayhelloReturn_type_info = new String[]{'sayhelloReturn','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://webapp.wtp','true','false'};
private String[] field_order_type_info = new String[]{'sayhelloReturn'};
}
}
and i have a apex class as below calling my WSDL apex:
public class WSContoller{
public WSContoller(ApexPages.StandardController controller) {
}
public String getHelloName() {
string MyReturn;
AxisWS.HelloWord stub = new AxisWS.HelloWord();
MyReturn = stub.sayhello('lhy');
return MyReturn ;
}
}
and lastly i created a Visualforce page to display the message from my webservice
<apex:page standardController="Account" extensions="WSContoller"> It will be a nice to get output from the controller<p>My webservice is now returning {!HelloName} !! </p> </apex:page>
i also setup my remote site
Remote Site Name: AxisWS *Remote Site URL: 192.168.0.10:8080
and when i open my account record i got this error
Content cannot be displayed: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'
can anyone pinpoint where seems to be the problem? im still learing APEX :)
thanks!
Hi,
are you trying to send messages to an endpoint in your LAN?
As salesforce is hosted in the cloud, the servers cannot reach your on-premise servers in this way. Your servers need to be reachable from the WWW and not local addresses.
Thanks,
James.
All Answers
Hi,
are you trying to send messages to an endpoint in your LAN?
As salesforce is hosted in the cloud, the servers cannot reach your on-premise servers in this way. Your servers need to be reachable from the WWW and not local addresses.
Thanks,
James.
Hi jays, thank you for reply!
ya, i hosted the webservice on my own desktop.
can you possibly guide how can i make my server reachable from salesforce?
i tried changed my endpoint to 175.143.x.x via http://whatismyipaddress.com/ and now i got IO Exception: Read timed out
apologies as im still very new for APEX :)
Hi Jays,
thanks for your hint! i actually forward my tomcat port and now able to connect already!