+ Start a Discussion
Scooter429Scooter429 

Visualforce - RPC WSDL Style

It appears that the "RPC" WSDL style is not presently supported by Visualforce.  Can someone please point me to the documentation on WSDL models supported by Visualforce.  More importantly what is the guidance for incorporating RPC-based WSDLs ?

We are presently getting the following error message.

Error: Failed to parse wsdl: Unsupported WSDL style 'rpc'.  Only supports Dcoument/litteral/wrapped services.

A WSDL document describes a Web service. A WSDL binding describes how the service is bound to a messaging protocol, particularly the SOAP messaging protocol. A WSDL SOAP binding can be either a Remote Procedure Call (RPC) style binding or a document style binding. A SOAP binding can also have an encoded use or a literal use. This gives you four style/use models.  Add to this collection a pattern which is commonly called the document/literal wrapped pattern and you have five binding styles to choose from when creating a WSDL file.
1.    RPC/encoded
2.    RPC/literal
3.    Document/encoded
4.    Document/literal
5.    Document/literal wrapped

* Reference: http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/ 



cheenathcheenath
Like the message suggests, wsdl2apex only support doc/lit/wrapped web services.

You can use the Http, HttpRequest, XmlStreamWriter and XmlStreamReader classes
to hand code your web service invoke. Then you can invoke any http endpoint using this
(need not be web service). It will be lot more code than using wsdl2apex.

HTHs,




HarmpieHarmpie
So what do I do then if a WSDL generates this error ?
 
(Error: Failed to parse wsdl: Unsupported WSDL style 'rpc'. Only supports Dcoument/literal/wrapped services. START_TAG seen ...ing style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>... @200:79)
 
Any other way (read: sample??) to use this WSDL or to connect to this service??


Message Edited by Harmpie on 11-19-2008 06:49 AM
Scott.MScott.M

I just ran into this problem, is there a solution other than hand coding and parsing the soap requests and responses? 

TehNrdTehNrd
I'm in the same boat. I can set up webservices when apex understands the WSDL but I haven't a clue how to set this up when it is a rpc wsdl. I have looked at the online documentation, force.com cookbook, and the developers guide but there appears to be no samples anywhere.
martin_wumartin_wu

Having the same problem here. I would like to integrate with a web service that is described with an "RPC" style WSDL. Will this style be supported by force.com? Are there ways of converted an RPC WSDL to the style that force.com understands?

 

Cheers, 

 

Martin

HarmpieHarmpie

To address a webservice that uses this type of wsdl is impossible by consuming the WSDL. In my case I used a http callout to the service, passing the parameters by url.

 

 

My class code:

 

global class TestWsClass { public static integer debug = 0; private static final string serviceUrl = 'https://ws1.webservices.nl/rpc/get-simplexml/internationalAddressSearchV2/<username>/<password>'; @future (callout=true) public static void doRequest(list<string> accids) { Account[] al = [ select Id, Name, BillingStreet,BillingState,BillingPostalCode,BillingCountry,Debug__c from Account where id in :accids LIMIT 200]; List<Account> updAcc = new List<Account>(); for (Account a: al) { String addressString = ''; if(a.Name!=null) { if(a.Name.length() > 0) { addressString += '/'+EncodingUtil.urlEncode(a.Name,'UTF-8'); } else { addressString += '/'; } } else { addressString += '/'; } // Use street as both Building and Address (and housenumer, which is not a default SFDC field) AND PO BOX if(a.BillingStreet!=null) { if(a.BillingStreet.length() > 0) { addressString += '/'+EncodingUtil.urlEncode(a.BillingStreet,'UTF-8')+'/'+EncodingUtil.urlEncode(a.BillingStreet,'UTF-8')+'/'+EncodingUtil.urlEncode(a.BillingStreet,'UTF-8')+'/'; } else { addressString += '////'; } } else { addressString += '////'; } // Locality = empty addressString += '/'; if(a.BillingPostalCode!=null) { if(a.BillingPostalCode.length() > 0) { addressString += '/'+EncodingUtil.urlEncode(a.BillingPostalCode,'UTF-8'); } else { addressString += '/'; } } else { addressString += '/'; } if(a.BillingState!=null) { if(a.BillingState.length() > 0) { addressString += '/'+EncodingUtil.urlEncode(a.BillingState,'UTF-8'); } else { addressString += '/'; } } else { addressString += '/'; } if(a.BillingCountry!=null) { if(a.BillingCountry.length() > 0) { addressString += '/'+EncodingUtil.urlEncode(a.BillingCountry,'UTF-8'); }else { addressString += '/'; } } else { addressString += '/'; } addressString += '/nl/nl'; xmldom dom = checkAddress(addressString,a); if(dom!=null) { System.debug('TESTING:'+dom.root.getValue('formatted_address')); a.Debug__c = dom.root.getValue('formatted_address'); updAcc.add(a); } } if(updAcc.size()>0) { update updAcc; } } public static xmldom checkAddress(String addr,Account a) { HttpRequest req = new HttpRequest(); //string url = TestWsClass.serviceUrl + EncodingUtil.urlEncode(addr,'UTF-8'); string url = TestWsClass.serviceUrl + addr; req.setEndpoint( url ); req.setMethod('GET'); xmldom dom = null; try { Http http = new Http(); HttpResponse response = http.send(req); System.Debug('STATUS:'+response.getStatusCode()); if (response.getStatusCode() != 200 ) { System.Debug('Response for '+url+':'+response); } else { dom = new xmldom(response.getBody()); System.Debug('URL:'+url); System.Debug('DOM:'+dom.toXmlString()); System.Debug('Postcode:'+dom.root.getValue('postcode')); System.Debug('Formatted address:'+dom.root.getValue('formatted_address')); //a.Debug__c = dom.root.getValue('formatted_address'); } } catch( System.Exception e) { System.Debug('Exception!!:'+e.getMessage()); } if ( TestWsClass.debug > 0 && dom != null ) { dom.dumpAll(); } return dom; } private static void dumpResponse(HttpResponse response) { xmldom dom = new xmldom( response.getBody() ); dom.dumpAll(); } }

 

and the trigger calling it

 

 

trigger testWs on Account (after update) { string[] todo = new string[]{}; if(Trigger.new[0].BillingPostalCode != Trigger.old[0].BillingPostalCode) { for (Account acc : Trigger.New) { todo.add((String)acc.Id); } TestWsClass.doRequest(todo); } }

 

Please note, that this is just a test, which updates a textfield with values I receive from the (address-validation) service. The code should be cleaner and bulk compliant, though. What is important here, is the part where I check whether the billinpostalcode has changed in the trigger. If I wouldn't, an error would occur because the @future method, would recall the trigger recursively.
Scott.MScott.M

Thanks for the response Harmpie,

 

I actually ended up doing a similar thing with http requests and the excellent XMLDom class. In some ways it's probably more effecient since you only need to implement the parts of the wsdl that you need so the code ends up with a smaller footprint. I suppose this advantage dimishes as you require more and more of the operations provided by the service. Either way it's a pain writing the code by hand. Auto generated by wsdl2apex or even better generated at runtime like the PHP library would be great.

vanessenvanessen

for my case,i have to integrate salesforce with magento which uses a wsdl with format RPC/encoded. I have the architecture of the wsdl, and i also have to url which end with the extension wsdl.As salesforce do not understand RPC?encoded i was skipping the part of wsdl2Apex and i am trying the HTTP callout as you suggested. but i do not know where to start.I need to calla method from the wsdl with 3 parameters a username,a pwd and an id ,and expect to get a list of info.

 

1. which url to use for the endpoint? the same as wsdl soap:address e.g http://192.168.1.31/soap/xx_reservation.php or to the wsdl itself : http://arianetest.smartbox.com/soap/xx_reservation.wsdl??

 

2. How do i call the method from HTTP Callout???

 

3. How do i pass a parameter to the function call??

 

thanks in anticipation for future replies.

kprkpr

Hi,

 

I'm having a similar issue. Were you able to solve yours?

 

Thanks,

kpr

vanessenvanessen

No,thus we did the other way. I created a webservice in salesforce and write the other side code in php using the php toolkit library to call the webservice.

R K 44R K 44
The errors message has mispelled. Currently the error shown is "Error: Failed to parse wsdl: Unsupported WSDL style 'rpc'.  Only supports Dcoument/litteral/wrapped services." It should have Document not Dcoument

User-added image