gpt4 book ai didi

web-services - (WS) stub 生成 - 不允许下划线?

转载 作者:行者123 更新时间:2023-12-02 00:08:18 24 4
gpt4 key购买 nike

我尝试从 this WSDL 生成 stub (不是我的网络服务,所以我不能更改名称!)

问题是我无法成功生成 stub ,因为在 wsdl 中是服务名称,其区别仅在于以“_”开头的服务,而另一个则没有。示例:_registerTest 和 registerTest

有人知道怎么解决吗?是否可以使用 Jaxb 生成 stub ?

我用 maven 试过:

<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.7.1</version>
<executions>
<execution>
<id>ws-source-gen-phase1</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<removeOldOutput>true</removeOldOutput>
<extension>true</extension>
<schemaDirectory>src/main/resources/</schemaDirectory>
<args>
<arg>-wsdl</arg>
<schemaFiles>src/main/resources/onyxexamservices.wsdl</schemaFiles>
<!-- <arg>-XautoNameResolution</arg> -->
</args>
<generatePackage>com.onyx.player.ws</generatePackage>
<generateDirectory>${project.build.directory}/generated-sources/xjc1</generateDirectory>
</configuration>
</execution>
</executions>
</plugin>

还有 wsimport:

wsimport onyxexamservices.wsdl

parsing WSDL...

Generating code...

Compiling code...

/Users/blub/Downloads/./de/bps/plugin/webservice/server/OnyxExamService.java:89: error:
method registerTest(long,String,byte[],Mapwrapper) is already defined in interface
OnyxExamService
public long registerTest(
^
/Users/blub/Downloads/./de/bps/plugin/webservice/server/OnyxExamService.java:114: error:
method registerStudent(long,long,byte[],Mapwrapper) is already defined in interface
OnyxExamService
public long registerStudent(
^
/Users/blub/Downloads/./de/bps/plugin/webservice/server/OnyxExamService.java:165: error:
method testControl(long,StudentIdsWrapper,int,Mapwrapper) is already defined in interface
OnyxExamService
public long testControl(
^
/Users/blub/Downloads/./de/bps/plugin/webservice/server/OnyxExamService.java:210: error:
method deregisterTest(long,String,Mapwrapper) is already defined in interface
OnyxExamService
public long deregisterTest(
^
4 errors
compilation failed, errors should have been reported

最佳答案

我认为删除下划线是为了生成尊重 Java code conventions 的名称(像 foo_bar 这样的名称在源代码中生成为 fooBar)。

如果你想保留名字,你可以申请一些customizations .

假设我在 c:\temp\src 中有我正在处理的文件,并且我在 c:\temp\dest 中生成源代码,我可以做(在一行上):

wsimport 
-keep
-d c:\temp\dest
-b c:\temp\src\fix.xml
c:\temp\src\onyxexamservices.wsdl

fix.xml 是我的自定义文件:

<jaxws:bindings wsdlLocation="C:\temp\src\onyxexamservices.wsdl"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:bindings node="wsdl:definitions/wsdl:portType[@name='OnyxExamService']/wsdl:operation[@name='_registerStudent']">
<jaxws:method name="_registerStudent" />
</jaxws:bindings>
<jaxws:bindings node="wsdl:definitions/wsdl:portType[@name='OnyxExamService']/wsdl:operation[@name='_registerTest']">
<jaxws:method name="_registerTest" />
</jaxws:bindings>
<jaxws:bindings node="wsdl:definitions/wsdl:portType[@name='OnyxExamService']/wsdl:operation[@name='_testControl']">
<jaxws:method name="_testControl" />
</jaxws:bindings>
<jaxws:bindings node="wsdl:definitions/wsdl:portType[@name='OnyxExamService']/wsdl:operation[@name='_deregisterTest']">
<jaxws:method name="_deregisterTest" />
</jaxws:bindings>
</jaxws:bindings>

关于web-services - (WS) stub 生成 - 不允许下划线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16976845/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com