You need to sign in to do that
Don't have an account?
Call SOAP
Hi
I need to call Soap, from my apex class, to fetch data and show in my VF page. How should i go about it.
I have got this sample SOAP request/response code from my vendor. I need to use mes:subscriberId and mes:scheduleId to get Data.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mes="http://XXXXX.net/ws/schemas/messages">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="XWSSGID-1261544568770-474929336" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>############</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">###########</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<mes:GetCheckImageRequest>
<!--You may enter the following 4 items in any order-->
<mes:subscriberId>XXXXXX</mes:subscriberId>
<!--Optional:-->
<mes:scheduleId>XXXXXXX</mes:scheduleId>
</mes:GetCheckImageRequest>
</soapenv:Body>
</soapenv:Envelope>
Response
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header ver:CPIIDA-BUILD="build-30676" ver:CPIIDA-BUILD-TIME="03-01-2012 06:01" ver:CPIISRV-BUILD="build-30693" ver:CPIISRV-BUILD-TIME="03-01-2012 06:04" ver:CPIIWSRV-BUILD="build-30489" ver:CPIIWSRV-BUILD-TIME="03-01-2012 06:09" xmlns:ver="http://XXXXX.net/ws/schemas/header/version"/>
<SOAP-ENV:Body>
<ns3:GetCheckImageResponse xmlns:ns3="http://XXXXX.net/ws/scmas/mages" xmlns:ns2="http://XXXXX.net/ws/schemas/types">
<ns3:subscriberId>XXXXXXX</ns3:subscriberId>
<ns3:scheduleId>XXXXXXX</ns3:scheduleId>
<ns3:transactionId>XXXXXXX</ns3:transactionId>
<ns3:externalReferenceId>XXXXXXX</ns3:externalReferenceId>
<ns3:checkImageFront>SUkqAAgAXXXX</ns3:checkImageFront>
<ns3:checkImageBack xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:commandStatus>1</ns3:commandStatus>
<ns3:errorMessage xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</ns3:GetCheckImageResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I am completely lost on how to do this, any kind of help will be appreciated.
Thanks
Sid
You can often get some of these WSDLs to import successfully by removing certain things — for instance WSDL2Apex only supports 1.1, and doesn't support multiple bindings, so the first thing I usually do is remove anything referring to SOAP 12.
Either way, below is some code you can use to try and make this request via the HTTPRequest object, obviously strXML is the XML to send, strAction is the action you're calling (you should be able to find this in the WSDL), and strEndPoint is the URL you need to reach. You'll need to add this to the list of authorised end points in your security settings.
All Answers
You can try to use the Apex2WSDL code generate to build Apex classes from WSDL.
You can invoke the Web Service from the Apex Controller via the generated classes from Apex2WSDL.
You'll need the WSDL for the Web Service to get started.
Take a look at the developer documenation http://www.salesforce.com/us/developer/docs/apexcode/index.htm and look at the section "
SOAP Services: Defining a Class from a WSDL Document"
So you mean i need my Vendor WSDL?
Without that its not possible to extract their data?
Obtaining the WSDL is definitely the easiest way to go about doing this, the only snag however, is that the WSDL2Apex functionality can be a little.. flakey ;)
For simple services with one call like this, you can actually use the HttpRequest class to make the request and send the XML data in the body. Try to get the WSDL first, but if you get stuck I can provide some sample code I've used for sending XML requests.
Thanks Matt. I have my vendore WSDl, but it has some tags which are not supported in Apex, like Annotation, due to which its not allowing me to create WSDL2Apex.
Also i just have to make 1 simple call, so if there is any workaround, to do that without WSDl, please provide me sample code. I tried to do that with HttpRequest, but i am not able to create HTTP header.
Thanks again for your time.
You can often get some of these WSDLs to import successfully by removing certain things — for instance WSDL2Apex only supports 1.1, and doesn't support multiple bindings, so the first thing I usually do is remove anything referring to SOAP 12.
Either way, below is some code you can use to try and make this request via the HTTPRequest object, obviously strXML is the XML to send, strAction is the action you're calling (you should be able to find this in the WSDL), and strEndPoint is the URL you need to reach. You'll need to add this to the list of authorised end points in your security settings.
Thanks Matt
Couple of questions
1. If i use HttpRequest, i dont need WSDL. Right?
2. If this is my SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mes="http://XXXXX.net/ws/schemas/messages">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="XWSSGID-1261544568770-474929336" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>############</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">###########</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<mes:GetCheckImageRequest>
<!--You may enter the following 4 items in any order-->
<mes:subscriberId>XXXXXX</mes:subscriberId>
<!--Optional:-->
<mes:scheduleId>XXXXXXX</mes:scheduleId>
</mes:GetCheckImageRequest>
</soapenv:Body>
</soapenv:Envelope>
What will be the strXML?
strAction = GetCheckImageRequest
What will be the strEndPoint? Do i need to ask my vendor about strEndPoint?
Thanks Again for your time.
That will be your XML, just fill in the right values in the appropriate places - give it a go and see what the results are.
Thanks. Tried that.
getting this error: