hi freeman
this is my main class for invoking.
import junit.framework.TestCase;
public class GeneratorTest extends TestCase {
public void testGen() {
WSDL2JavaGenerator gen = new WSDL2JavaGenerator();
gen.setAll(true);
gen
.setWsdlName("G:\\simpleWS.wsdl");
gen.setPackagePath("G:\\Project\\src\\trunk\\projects\\tis-core\\target\\generate\\");
gen.generate();
}
}
2010/11/10 Freeman Fang <[email protected]>
> Hi,
>
> Could you please post you whole pom.xml, the main class, how you invoke the
> main class?
> If you can append a buildable and runnable testcase, it would be great.
>
> Freeman
>
> On 2010-11-10, at 下午5:56, Wang Jinglong wrote:
>
> in 2010/11/10 17:47, Freeman Fang wrote:
>>
>>>
>>> On 2010-11-10, at 下午5:38, Wang Jinglong wrote:
>>>
>>> hi,
>>>>
>>>> in my environmen,i need to use wsdl4java to generate java code in
>>>> runtime.
>>>> so i need call wsdl4java api that i can generate code in runtime(may be
>>>> not in web apps).
>>>>
>>>> then i run my test case,that throw an exception:
>>>> org.apache.cxf.tools.common.ToolException: Could not find jaxws frontend
>>>> within classpath
>>>> at
>>>>
>>>> org.apache.cxf.tools.wsdlto.core.PluginLoader.getFrontEnd(PluginLoader.java:241)
>>>>
>>>> at
>>>>
>>>> org.apache.cxf.tools.wsdlto.core.PluginLoader.getFrontEndProfile(PluginLoader.java:377)
>>>>
>>>> at
>>>> org.apache.cxf.tools.wsdlto.WSDLToJava.loadFrontEnd(WSDLToJava.java:64)
>>>> at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:96)
>>>> at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
>>>>
>>>> that's means no jar of jaxws frontend in my classpath.
>>>>
>>>> how to add jaxws frontend into my classpath?
>>>>
>>>> i'm use maven.
>>>>
>>>> pom dependencies:
>>>>
>>>> <dependencies>
>>>> <dependency>
>>>> <groupId>wsdl4j</groupId>
>>>> <artifactId>wsdl4j</artifactId>
>>>> <version>1.6.2</version>
>>>> </dependency>
>>>> <dependency>
>>>> <groupId>org.apache.ws.schema</groupId>
>>>> <artifactId>XmlSchema</artifactId>
>>>> <version>1.4.5</version>
>>>> </dependency>
>>>> <dependency>
>>>> <groupId>dom4j</groupId>
>>>> <artifactId>dom4j</artifactId>
>>>> <version>1.6.1</version>
>>>> <type>jar</type>
>>>> <scope>compile</scope>
>>>> </dependency>
>>>> <dependency>
>>>> <groupId>junit</groupId>
>>>> <artifactId>junit</artifactId>
>>>> <version>4.8.2</version>
>>>> <type>jar</type>
>>>> <scope>compile</scope>
>>>> </dependency>
>>>> <dependency>
>>>> <groupId>log4j</groupId>
>>>> <artifactId>log4j</artifactId>
>>>> <version>1.2.15</version>
>>>> <type>jar</type>
>>>> <scope>compile</scope>
>>>> </dependency>
>>>> <dependency>
>>>> <groupId>ws-commons</groupId>
>>>> <artifactId>axiom</artifactId>
>>>> <version>1.1.1</version>
>>>> <type>jar</type>
>>>> <scope>compile</scope>
>>>> </dependency>
>>>> <dependency>
>>>> <groupId>org.apache.cxf</groupId>
>>>> <artifactId>cxf-tools-wsdlto-core</artifactId>
>>>> <version>2.3.0</version>
>>>> <type>jar</type>
>>>> <scope>compile</scope>
>>>> </dependency>
>>>> <dependency>
>>>> <groupId>org.apache.cxf</groupId>
>>>> <artifactId>cxf-rt-frontend-jaxws</artifactId>
>>>> <version>2.3.0</version>
>>>> <type>jar</type>
>>>> <scope>compile</scope>
>>>>
>>> Change it to
>>> <scope>runtime</scope>
>>>
>>> to see if it helps
>>>
>>> Freeman
>>>
>>>> </dependency>
>>>> </dependencies>
>>>>
>>>
>>>
>>>> thx a lot!
>>>>
>>>
>>>
>>> thx Freeman,
>> i change it to runtime,but the exception same to.
>> this is my class for calling wsdl4java
>>
>> =============================================
>> import java.util.ArrayList;
>> import java.util.List;
>>
>> import org.apache.cxf.tools.common.ToolContext;
>> import org.apache.cxf.tools.wsdlto.WSDLToJava;
>>
>> public class WSDL2JavaGenerator {
>> private String wsdlName;
>> private String packagePath;
>> private String bindingName;
>> private boolean all;
>> private String sourcePath;
>>
>> public String getWsdlName() {
>> return wsdlName;
>> }
>>
>> public void setWsdlName(String wsdlName) {
>> this.wsdlName = wsdlName;
>> }
>>
>> public String getPackagePath() {
>> return packagePath;
>> }
>>
>> public void setPackagePath(String packagePath) {
>> this.packagePath = packagePath;
>> }
>>
>> public String getBindingName() {
>> return bindingName;
>> }
>>
>> public void setBindingName(String bindingName) {
>> this.bindingName = bindingName;
>> }
>>
>> public boolean isAll() {
>> return all;
>> }
>>
>> public void setAll(boolean all) {
>> this.all = all;
>> }
>>
>> public String getSourcePath() {
>> return sourcePath;
>> }
>>
>> public void setSourcePath(String sourcePath) {
>> this.sourcePath = sourcePath;
>> }
>>
>> private String[] argsBuilder(){
>> List<String> argsList = new ArrayList<String>();
>> if(this.getPackagePath()!=null){
>> argsList.add("-p");
>> argsList.add(this.getPackagePath());
>> }else if (all) {
>> argsList.add("-all");
>> }else if (this.getSourcePath()!=null) {
>> argsList.add("-d");
>> argsList.add(this.getSourcePath());
>> }else if (this.getWsdlName()!=null) {
>> argsList.add(this.getWsdlName());
>> }
>> argsList.add("-V");
>> String args[] = null;
>> if (argsList.size()!=0) {
>> args = argsList.toArray(new String[0]);
>> }
>> return args;
>> }
>>
>> public void generate() {
>> WSDLToJava wsdlToJava = new WSDLToJava();
>> if (this.argsBuilder()!=null) {
>> wsdlToJava.setArguments(this.argsBuilder());
>> try {
>> wsdlToJava.run(new ToolContext());
>> } catch (Exception e) {
>> e.printStackTrace();
>> }
>> }else {
>>
>> }
>>
>> }
>> }
>> ===================================================
>>
>> regard
>>
>
>
> --
> Freeman Fang
>
> ------------------------
>
> FuseSource: http://fusesource.com
> blog: http://freemanfang.blogspot.com
> twitter: http://twitter.com/freemanfang
> Apache Servicemix:http://servicemix.apache.org
> Apache Cxf: http://cxf.apache.org
> Apache Karaf: http://karaf.apache.org
> Apache Felix: http://felix.apache.org
>
>
--
命运并不是不可战胜的,平等需要自己去争取,平等不会白白让你取得。想要平等,必须有劳动,有付出,有汗水,有坚定的信念。