• edgar.yucel
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
Hello, I'm reviewing the information REST API, salesforce.com and I wonder if I can do with this tool integration with Oracle in real time, I need to read data from the database and display it within salesforce.com.

I hope someone has had a similar experience,

Greetings.
 
 

 

Hi all, I'm trying to consume a web service, which I modified to import within Salesforce, have created the classes and methods Generated by wsdl2apex and I'm trying to eat it. So far the service has no security. When trying to invoke it I get an error:
 "Web service calloutfailed: Unexpected element. Parser WAS expecting element 'http://SalesforceWS:testWebServiceReturn' but found 'http://SalesforceWS:testWebServiceResponse.'" 

I hope some of you can guide me to solve it and consume it. The service method receives a string and returns a string in uppercase.

I have a visualforce and controller to invoke the methods, this is the code snippet:
<apex:page controller="Controller">
<apex:pageBlock >
	<apex:form >
		<apex:inputText value="{!texto}"/>
		
		
		<apex:outputPanel id="panel" >
			LA RESPUESTA ES: 
			{!respuesta}
		</apex:outputPanel>
		<br></br>
		<apex:commandButton value="Consultar" action="{!ejecutaMetodo}" rerender="panel"/>
			
	</apex:form>
	
</apex:pageBlock>
</apex:page>

 

global class Controller {
    
    String texto='';
    String respuesta='';
    
    public String getTexto()
    {
        return this.texto;
    }
    
    public String getRespuesta()
    {
        return this.respuesta;
    }
    
    public void setTexto(String text)
    {
        this.texto=text;
    }
    
    public PageReference ejecutaMetodo()
    {       
    	      
         prueba.SalesforceWSPort testService=new prueba.SalesforceWSPort();
         this.respuesta=testService.testWebService(this.texto);
         return null;
    }

}

 

   This is the wsdl:

 

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://SalesforceWS" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://SalesforceWS" xmlns:intf="http://SalesforceWS" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<wsdl:types>
		<schema elementFormDefault="qualified" targetNamespace="http://SalesforceWS" xmlns="http://www.w3.org/2001/XMLSchema">
			<element name="testWebService">
				<complexType>
					<sequence>
						<element name="testString" type="xsd:string"/>
					</sequence>
				</complexType>
			</element>
			<element name="testWebServiceReturn">
				<complexType>
					<sequence>
						<element name="testWebServiceReturn" type="xsd:string"/>
					</sequence>
				</complexType>
			</element>
		</schema>
	</wsdl:types>

   <wsdl:message name="testWebServiceReturn">
		<wsdl:part element="impl:testWebServiceReturn" name="parameters"/>
   </wsdl:message>
   <wsdl:message name="testWebServiceRequest">
      <wsdl:part element="impl:testWebService" name="parameters"/>
   </wsdl:message>

   
   <wsdl:portType name="SalesforceWSPort">

		<wsdl:operation name="testWebService">
			<wsdl:input message="impl:testWebServiceRequest" name="testWebServiceRequest"/>
			<wsdl:output message="impl:testWebServiceReturn" name="testWebServiceReturn"/>
		</wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="SalesforceWSSoapBinding" type="impl:SalesforceWSPort">
		<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
		
		<wsdl:operation name="testWebService">
			<wsdlsoap:operation soapAction=""/>
			<wsdl:input name="testWebServiceRequest">
				<wsdlsoap:body use="literal"/>
			</wsdl:input>
			
			<wsdl:output name="testWebServiceReturn">
				<wsdlsoap:body use="literal"/>
			</wsdl:output>
		</wsdl:operation>

   </wsdl:binding>

   
   <wsdl:service name="SalesforceWSService">

      <wsdl:port binding="impl:SalesforceWSSoapBinding" name="SalesforceWSPort">

         <wsdlsoap:address location="endpoint...."/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>

 this is the generatedCode:

 

//Generated by wsdl2apex

public class prueba {
    public class testWebService_element {
        public String testString;
        private String[] testString_type_info = new String[]{'testString','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://SalesforceWS','true','false'};
        private String[] field_order_type_info = new String[]{'testString'};
    }
    public class SalesforceWSPort {
        public String endpoint_x = 'myendpoint';
        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://SalesforceWS', 'prueba'};
        public String testWebService(String testString) {
            prueba.testWebService_element request_x = new prueba.testWebService_element();
            prueba.testWebServiceReturn_element response_x;
            request_x.testString = testString;
            Map<String, prueba.testWebServiceReturn_element> response_map_x = new Map<String, prueba.testWebServiceReturn_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://SalesforceWS',
              'testWebService',
              'http://SalesforceWS',
              'testWebServiceReturn',
              'prueba.testWebServiceReturn_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.testWebServiceReturn;
        }
    }
    public class testWebServiceReturn_element {
        public String testWebServiceReturn;
        private String[] testWebServiceReturn_type_info = new String[]{'testWebServiceReturn','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://SalesforceWS','true','false'};
        private String[] field_order_type_info = new String[]{'testWebServiceReturn'};
    }
}

 

 

  this is the error when i click on button:


Greetings.