• leela krishna 6
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
//visual force page starts
<!-- Page: -->
<apex:page controller="mysrc">
    <apex:pageBlock >   
     <apex:form >
        <apex:pageBlockSection >
            <apex:inputText value="{!srcCity1}" label="City1"/>
            <apex:inputText value="{!srcCity2}" label="City2"/>   
            <apex:commandButton value="Search" action="{!getCities}"/> 
        </apex:pageBlockSection>
    </apex:form>     
    <apex:pageBlockSection title="RawResponse" >    
        <apex:outputText title="raw response" value="{!result}"></apex:outputText>    
    </apex:pageBlockSection>
    <apex:pageBlockSection title="Structure Format" >  
      <apex:dataTable value="{!city1}" var="dd">
        <apex:column headerValue="Name">                     
         <apex:outputText value="{!dd['name']}" />          
        </apex:column>
      </apex:dataTable>
    </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>
////////////////////////////////////visualforce page ends////////
///////////mycontroller//////

public class mysrc {

    public string srcCity1{get;set;}    
    public string srcCity2{get;set;} 
    Public string result{get;set;} 
    
    Public string stresult{get;set;}
    public List<Object> city1{get;set;} 
    
    

    
    public PageReference getCities() {
        
        Http http = new Http();
        HttpRequest req = new Httprequest();
        req.setEndPoint('http://samples.openweathermap.org/data/2.5/weather?q=bangalore,ka&appid=b1b15e88fa797225412429c1c50c122a1');
        req.setMethod('GET');
        HttpResponse res =  http.send(req);        
        if(res.getStatusCode() == 200){
            result = res.getBody();
            ////////////////
           // Deserialize the JSON string into collections of primitive data types.
    Map<String, Object> stresult = (Map<String, Object>) JSON.deserializeUntyped(result);
    // Cast the values in the 'animals' key as a list
       List<Object> city1 = new list<object>();       
    System.debug('Received the following message:'+stresult.get('base'));    
    city1.add(stresult);    
    System.debug('Received the following City:'+city1);
      }         
        return null;
    }
}

User-added image

//////////////////////////////////////////////////////////////////////////////
1.The section i just return json respone as a string and displayes as rawrespone. And this is working as you seen the image first section
2.From the same response i want to show in table colums the following steps i have taken
    using map i will initialize and assigned that to city1 list. as if you seen in my controller
but i will not able to show the values . nothing is shown . please help me . I'm new to salesforce


    


 
//visual force page starts
<!-- Page: -->
<apex:page controller="mysrc">
    <apex:pageBlock >   
     <apex:form >
        <apex:pageBlockSection >
            <apex:inputText value="{!srcCity1}" label="City1"/>
            <apex:inputText value="{!srcCity2}" label="City2"/>   
            <apex:commandButton value="Search" action="{!getCities}"/> 
        </apex:pageBlockSection>
    </apex:form>     
    <apex:pageBlockSection title="RawResponse" >    
        <apex:outputText title="raw response" value="{!result}"></apex:outputText>    
    </apex:pageBlockSection>
    <apex:pageBlockSection title="Structure Format" >  
      <apex:dataTable value="{!city1}" var="dd">
        <apex:column headerValue="Name">                     
         <apex:outputText value="{!dd['name']}" />          
        </apex:column>
      </apex:dataTable>
    </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>
////////////////////////////////////visualforce page ends////////
///////////mycontroller//////

public class mysrc {

    public string srcCity1{get;set;}    
    public string srcCity2{get;set;} 
    Public string result{get;set;} 
    
    Public string stresult{get;set;}
    public List<Object> city1{get;set;} 
    
    

    
    public PageReference getCities() {
        
        Http http = new Http();
        HttpRequest req = new Httprequest();
        req.setEndPoint('http://samples.openweathermap.org/data/2.5/weather?q=bangalore,ka&appid=b1b15e88fa797225412429c1c50c122a1');
        req.setMethod('GET');
        HttpResponse res =  http.send(req);        
        if(res.getStatusCode() == 200){
            result = res.getBody();
            ////////////////
           // Deserialize the JSON string into collections of primitive data types.
    Map<String, Object> stresult = (Map<String, Object>) JSON.deserializeUntyped(result);
    // Cast the values in the 'animals' key as a list
       List<Object> city1 = new list<object>();       
    System.debug('Received the following message:'+stresult.get('base'));    
    city1.add(stresult);    
    System.debug('Received the following City:'+city1);
      }         
        return null;
    }
}

User-added image

//////////////////////////////////////////////////////////////////////////////
1.The section i just return json respone as a string and displayes as rawrespone. And this is working as you seen the image first section
2.From the same response i want to show in table colums the following steps i have taken
    using map i will initialize and assigned that to city1 list. as if you seen in my controller
but i will not able to show the values . nothing is shown . please help me . I'm new to salesforce


    


 
Hi Everyone , I am stuck
I am currently testing out some functionality where I have to pass 1 record value from one instance to other instance of salesforce using SOAP webservice and WSDL , steps being followed by me :
step1 :  wrote a webservice class in SFDC instance1
step2 : after successfull creation , clicked on GENERATE WSDL on the same page and saved it.
step 3 : opened my SFDC instance2 and in Apex class -- clicked on Generate from  WSDL , here i refered to the wsdl class which I had obtained from SFDC instance 1.
step 4 :  now I am working in my another controller class in sfdc Instance2 and trying to fetch the data retured from WSDL class (by intiating it and calling my method in it ) but it is saying
"System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor="

I know I am missing many things :
- call login() with username and password
- I have to fetch the session ID and use it

even I want to set them up , but I am unable to find out them in my "APEX generated from wsdl class" . There is only 1 method with the name LoginINFO (no username or password in the method) in my apex generated frm WSDL
please advise and assist me.
Thanks