• Saranya M
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
How to call a soap webservice

I am trying to consume a Soap webservice.  I have generated a class(partnerSoapSforceCom.Soap)  from Partner WSDL. Also I have generated a class(soapSforceComSchemasClassSaransoaps) from the WSDL created from custom webservice.  The webservice contains a single method named Hello which accepts a string and displays a string.

I'm new to integration. When I execute the below code, I'm getting an error msg 'System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: No service available for class'. Please someone help me to modify it.

WEbservice : 

global class SaranSoapService
{
    webService static String hello(String Name)
    {
        return 'Hi '+Name+' ! :D';
    }
}

This is the code which I executed.

partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap();
String username = 'My username;
String password = 'My password';
partnerSoapSforceCom.LoginResult loginResult = sp.login(username, password);
system.debug('   loginResult ' + loginResult);
system.debug(loginresult.sessionid);
soapSforceComSchemasClassSaransoaps  ap = new soapSforceComSchemasClassSaransoaps();
soapSforceComSchemasClassSaransoaps.SessionHeader_element sessionHeader = new soapSforceComSchemasClassSaransoaps.SessionHeader_element ();
sessionHeader.sessionId = loginResult.sessionId;
soapSforceComSchemasClassSaransoaps.SaranSoapService callsoap = new  soapSforceComSchemasClassSaransoaps.SaranSoapService();
string retval=callsoap.hello('Saranya');
system.debug(retval);
I have created the below Visualforce page which gets the data for the Opportunity object from the user. The Opportunity object has a field - Account name which contains a lookup to the Account object. But when I refer it through the Inputfield using {!opportunity.account.name}, it is displayed as a text box and not as a lookup field to Account object. Can someone please tell me how to modify the code? 

<apex:page controller="opptycontroller" tabStyle="Opportunity">
<apex:sectionHeader title="New Customer Opportunity" subtitle="Step 2 of 3"/>
    <apex:form >
        <apex:pageBlock title="Opportunity information" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!step3}" value="Next"/>
            </apex:pageBlockButtons>
        <apex:pageBlockSection title="Opportunity products">
            <apex:inputField id="opportunityType" value="{!opportunity.type}"/>
            <apex:inputField id="opportunityLeadSource" value="{!opportunity.LeadSource}"/>
            <apex:inputField id="opportunityProbability" value="{!opportunity.Probability}"/>
           <apex:inputField id="opportunityAccountName" value="{!opportunity.account.name}"/>
        </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
I have written a trigger on event for contact object. If I try to create an event for Merchandise object, the below trigger is getting fired and throws an error.

How I can restrict the below trigger to work only for events created on contact object.

trigger ContactSysIDEvent on Event (before insert) {
    ID evid;
   for (event e:trigger.new)
    { evid=e.whoid;
    contact m123 =[select name,id_type__C,sys_id__c,siebel_id__C from contact
                          where id=:evid];
    if(m123.id_type__C=='Sys ID')
        { e.Contact_sys_ID__c=m123.sys_id__c; }
        else{ e.contact_sys_id__C=m123.siebel_id__C; }
}
}
I'm trying to update activity custom field - contact sys id with the value from sys id or siebel id based on the id type field

trigger ContactSysID on Event (before insert) { ID evid; for (event e:trigger.new){ evid=e.whatid; } event e=[select id,contact_sys_id__c from event where whatid=:evid]; Merchandise__c merch=[SELECT TYPEOF What WHEN Merchandise__C THEN name,id_type__C,sys_id__c,siebel_id__C END FROM event where WHAT.TYPE='Merchandise__c' limit 1]; For (Merchandise__C m:merch){ if(m.id_type__C=='Sys ID'){ e.Contact_sys_ID__c=m.sys_id__c; } else{ e.contact_sys_id__C=m.siebel_id__C; }
}
I have written a trigger on event for contact object. If I try to create an event for Merchandise object, the below trigger is getting fired and throws an error.

How I can restrict the below trigger to work only for events created on contact object.

trigger ContactSysIDEvent on Event (before insert) {
    ID evid;
   for (event e:trigger.new)
    { evid=e.whoid;
    contact m123 =[select name,id_type__C,sys_id__c,siebel_id__C from contact
                          where id=:evid];
    if(m123.id_type__C=='Sys ID')
        { e.Contact_sys_ID__c=m123.sys_id__c; }
        else{ e.contact_sys_id__C=m123.siebel_id__C; }
}
}
I'm trying to update activity custom field - contact sys id with the value from sys id or siebel id based on the id type field

trigger ContactSysID on Event (before insert) { ID evid; for (event e:trigger.new){ evid=e.whatid; } event e=[select id,contact_sys_id__c from event where whatid=:evid]; Merchandise__c merch=[SELECT TYPEOF What WHEN Merchandise__C THEN name,id_type__C,sys_id__c,siebel_id__C END FROM event where WHAT.TYPE='Merchandise__c' limit 1]; For (Merchandise__C m:merch){ if(m.id_type__C=='Sys ID'){ e.Contact_sys_ID__c=m.sys_id__c; } else{ e.contact_sys_id__C=m.siebel_id__C; }
}
Hi I am trying to integrate salesforce.com with Oracle Apps using BPEL. I have published my BPEL as a webservice in our test server and had created an apex class which calls this webservice. Later I am invoking this using an S-control button in Accounts tab.

But I am getting the following error when I invoke the button.

**
{faultcode:’soapenv”Client’, faultstring:’System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element ‘http://schemas.xmlsoap.org/soap/envelope/:Envelope’ but found ‘:html’

Class.wwwTrianzCom.Create_AccountPort.process: line 15, column 13
Class.AccountWrapper.CreateFunction: line 5, column 10
**

Please help me to figure out the problem.

Thank you, Aneesh