-2

I have a WSDL file generated from apex class (in salesforce environment). I want to call method of the apex class from my java program. I am new in java so please help me out. Even i do not have any IDE. I am running java program from command promt. Also If any software is required The approch i was folling was wrong now I have gone through following link https://developer.salesforce.com/page/Introduction_to_the_Force.com_Web_Services_Connector now I am unable to understand what is this import com.sforce.soap.enterprise.Connector;

Shik
  • 27
  • 7
  • You will need to tell a little more about your Java program. I doubt there is a way to instruct an arbitrary Java program to consume a webservice just by feeding it an arbitrary wsdl. – Filburt Mar 18 '15 at 15:31
  • I have just created a java program with two user inputs – Shik Mar 19 '15 at 06:06
  • Now I am able to parse my WSDL and got .java files . now what to do?? – Shik Mar 19 '15 at 10:29
  • I would recommend consulting [this question and it's answers](http://stackoverflow.com/q/4172118/205233) for gaining a better understanding. Also visit questions listed under "Related" (under the "Looking for a job" advertisement). Also searching the web for specific examples related to consuming apex-generated web service methods should deliver some results. Being new to a technology is no excuse for not even trying yourself. You will not get a step-by-step tutorial here. – Filburt Mar 19 '15 at 11:01
  • I have tried an am getting following errror – Shik Mar 19 '15 at 15:02

1 Answers1

0

The most basic way would be to create the client classes with wsimport (JDK) from the command line, for example:

wsimport http://example.com/service?wsdl

or, if you have the wsdl file locally...

wsimport c:/temp/mywsdl.wsdl

This will, in many cases, be enough to create the .class files for your client. If you need the .java files, use

wsimport -Xnocompile http://example.com/service?wsdl

Using the generated classes, you should be able to write a program that connects to the WebService.

More infos about wsimport, see here https://docs.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html

Florian Schaetz
  • 10,454
  • 5
  • 32
  • 58
  • 1
    Well, without the error, helping you will probably be a little bit difficult. – Florian Schaetz Mar 19 '15 at 06:40
  • I am new, I am trying first time . please help . any link or pdf ?? – Shik Mar 19 '15 at 09:12
  • Now I am able to parse my WSDL and got .java files . now what to do?? – Shik Mar 19 '15 at 10:29
  • 1
    Unfortunately, the next step is to take these java files and use them in your java program. Sorry, this is the step where you have to actually code in java and reading a forum will not help you there. I would try starting with some basic java tutorial until you have learned enough to do it. – Florian Schaetz Mar 19 '15 at 14:33
  • Exception in thread "main" com.sun.xml.internal.ws.streaming.XMLStreamReaderExce ption: XML reader error: javax.xml.stream.XMLStreamException: ParseError at [row ,col]:[12,19] Message: The entity name must immediately follow the '&' in the entity reference – Shik Mar 19 '15 at 14:59
  • import javax.xml.namespace.QName; import java.net.URL; class TimeClient { public static void main(String args[ ]) throws Exception { URL baseUrl,url;https://ap2.salesforce.com/services/Soap/class/test //url = new URL("https://ap2.salesforce.com/services/wsdl/class/test?wsdl"); url = new URL("https://ap2.salesforce.com/services/wsdl/class/test"); QName qname = new QName("http://soap.sforce.com/schemas/class/test", "testService"); Service service = Service.create(url, qname); TestService eif = service.getPort(TestService.class); } } – Shik Mar 19 '15 at 15:01
  • @Shik There's no point in dumping some code into comments. Editing your question would be the right thing to do but as Florian already said: It is simply not possible to spoonfeed you through developing a complete webservice client application. You will need to search a tutorial that fits your current level yourself. It is not going to happen here. This doesn't mean people here are evil towards you - it's just not possible to tutor you through a learning process of several weeks. – Filburt Mar 19 '15 at 16:16