如图所示,有 4 种方法可以在 Axis 2 中创建客户端
1.building an AXIOM based client,
2.generating a client using Axis2 Databinding Framework (ADB),
3.generating a client using XMLBeans,
4.and generating a client using JiBX
Run Code Online (Sandbox Code Playgroud)
谁能告诉我,我们如何决定应该使用什么方法。请指导我。
我是网络服务开发的新手。我将 Netbeans 7.0 与 Axis2 插件和 Tomcat 7 一起使用。
我为定义 Web 方法的服务器组件创建了一个项目,然后为客户端组件创建了另一个项目。通过选择 New -> Webservice Client 在 Netbeans 中创建客户端。
当您在 Netbeans 中选择 New -> Webservice Client 时,它会立即要求您提供 WSDL URL。所以当然我从我的本地 Tomcat 安装中给了它 WSDL URL。但是当我将它作为一个真正的应用程序分发时呢?用户不会将他们的客户端指向http://localhost:8080/axis2/services/ ?wsdl。我的意思是,当从 IDE 运行客户端时,一切正常,但是当我分发它时(这是一个劳动力管理应用程序,您可以在一个或多个客户端上打卡/下班,并且将考勤卡写入中央数据库),每个客户端都需要能够指向它应该连接到的任何生产服务器的 web 服务 URL。
我想将 web 服务 URL 存储在属性文件中,但不知道在客户端以编程方式执行什么操作来调用从属性文件加载的 URL。
在我客户的 dist 文件夹中,如果我打开 netbeans 用 WinZip 创建的 JAR,我会看到一个文件名 jax-ws-catalog.xml,其中包含 URL(指向 localhost)。我假设这是运行时使用的 URL 的来源。
那么解决这个问题的正确方法是什么?我四处搜索,但我在 google 搜索中发现的东西往往显示 webservice 调用的方式与 Netbeans 放在一起的自动生成的代码完全不同,我想要一些特定于如何的信息Netbeans 创建了一个 Web 服务客户端,这样我就不会为了让 IDE 覆盖它们而最终进行更改。
谢谢!对不起,很长的解释。
-吉姆
我在Eclipse中有wsdl文件,我通过axis2插件生成客户端.
这些文件正生成到源文件夹中名为com.mycompany.stub的包中.
我想将生成的源文件的包名称更改为com.mycompany.ws.workflow
我在哪里可以在wsdl文件中执行此操作?
尝试2天后获得Maven 3.0.3 + axis2-wsdl2code-maven-plugin 1.5.4与jaxbri数据绑定工作.错误信息:
java.lang.RuntimeException: JAX-B RI JARs not on classpath
at org.apache.axis2.wsdl.codegen.extension.JAXBRIExtension.engage(JAXBRIExtension.java:78)
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:224)
Run Code Online (Sandbox Code Playgroud)
POM:
...
<properties>
<axis2ReleaseVersion>1.5.4</axis2ReleaseVersion>
<axiomReleaseVersion>1.2.7</axiomReleaseVersion>
<wodenReleaseVersion>1.0M8</wodenReleaseVersion>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>${axis2ReleaseVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>${axiomReleaseVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
<version>${axiomReleaseVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-dom</artifactId>
<version>${axiomReleaseVersion}</version>
</dependency>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.5.4</version>
<configuration>
<generateServerSide>true</generateServerSide>
<generateServerSideInterface>true</generateServerSideInterface>
<generateAllClasses>true</generateAllClasses>
<!--<generateServicesXml>true</generateServicesXml> -->
<!--<allPorts>true</allPorts> -->
<!--<backwardCompatible>true</backwardCompatible> -->
<!--<unwrap>true</unwrap> -->
</configuration>
<executions>
<execution>
<goals>
<goal>wsdl2code</goal>
</goals>
<configuration>
<packageName>xyz</packageName>
<wsdlFile>${basedir}/src/main/resources/wsdl/Service.wsdl</wsdlFile>
<databindingName>jaxbri</databindingName>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
即使将jaxb-ri jar设置为依赖项也行不通:
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-jaxbri</artifactId>
<version>1.5.4</version> …Run Code Online (Sandbox Code Playgroud) 我想在我们的平台上提供REST支持.我们已经在我们的框架中集成了Axis 2.Axis 2正在支持REST.所以我在考虑使用Axis 2本身来提供REST支持.
http://axis.apache.org/axis2/java/core/docs/rest-ws.html
我还发现了另一篇关于如何使用Axis 2创建RESTful Web服务的博客文章.
但在上面的例子中,似乎我必须修改生成的WSDL以支持REST类型的调用.我必须修改轴2生成的默认WSDL2.0,修改它并在aar文件中再次打包并部署服务.所以这一次,它不使用生成wsdl,而是使用打包的WSDL并使用此WSDL来创建轴服务.这是一个问题,我必须以某种方式克服.
但Axis 2是否支持所有REST功能?我发现它支持指定要使用的HTTPMethod,HTTPLocation,InputSerialization,OutputSerialization.这些足以说明我们提供REST支持吗?
保罗先生,谢谢
我有一个需要生成xml的服务.目前我使用jaxb和Marshaller使用StringWriter创建xml.
这是我得到的当前输出.
<CompanyName>Bakery é &</CompanyName>
Run Code Online (Sandbox Code Playgroud)
虽然这可能适用于某些Web服务,但我需要转义特殊的unicode字符.令我的xml的服务需要有这样的服务:
<CompanyName>Bakery é &</CompanyName>
Run Code Online (Sandbox Code Playgroud)
如果我使用StringEscapeUtils,commons-lang我最终会得到像下面这样的东西.这个也不起作用:
<CompanyName>Bakery &#233; &amp;</CompanyName>
Run Code Online (Sandbox Code Playgroud)
是否有一些Marshaller设置允许我将这些特殊字符编码为十进制值?
我按如下方式配置了axistools-maven-plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<wsdlDirectory>/src/main/resources</wsdlDirectory>
<wsdlFiles>
<wsdlFile>adjustment.wsdl</wsdlFile>
</wsdlFiles>
<keep>true</keep>
<allElements>true</allElements>
<outputDirectory>/src/main/java</outputDirectory>
<subPackageByFileName>true</subPackageByFileName>
<useEmitter>true</useEmitter>
<wsdlVersion>2</wsdlVersion>
</configuration>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但我的wsdl文件没有被正确引用.配置是否正确?
我总是得到以下信息
[INFO] Nothing to generate. All WSDL files are up to date.
Run Code Online (Sandbox Code Playgroud) 我是Maven和Axis2的新手.我的项目包括三个模块:客户端,接口和服务器.服务是基于POJO的.WSDL正在服务器模块上构建.接口模块包含服务接口和bean等常见内容.
我应该将WSDL生成(或手动复制)到接口模块中吗?我应该在客户端模块生成客户端代码吗?模块结构好吗?我想做的就是使构建过程自动化但严格结构化.
我正在尝试理解ws-security签名和加密.我遵循了这个指南.如前所述,我已经安装了rampart,已*.aar成功创建相关文件并将其部署在tomcat servlet引擎中,将org.bouncycastle.jce.provider.BouncyCastleProviderBouncy Castle安全提供程序(示例代码中使用的公钥加密功能所必需)添加到JVM安全配置(lib/security/java.security文件),将Bouncy Castle JAR添加到Axis2安装的lib目录和Axis2服务器应用程序的WEB-INF/lib目录中.(这是运行给定示例的设置)但是在运行所描述的示例时,我收到以下错误
[java] Connecting to http://localhost:8080/axis2/services/library-signencr
[java] Exception in thread "main" org.apache.axis2.AxisFault: SOAP message MUST NOT contain a Document Type Declaration(DTD)
[java] at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
[java] at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:123)
[java] at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
[java] at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
[java] at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
[java] at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
[java] at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
[java] at com.sosnoski.ws.library.adb.LibrarySignencrStub.getBook(LibrarySignencrStub.java:205)
[java] at com.sosnoski.ws.library.adb.WebServiceClient.main(WebServiceClient.java:83)
[java] Caused by: org.apache.axiom.om.OMException: SOAP message MUST NOT contain a Document Type Declaration(DTD)
[java] at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createDTD(StAXSOAPModelBuilder.java:455)
[java] at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:282) …Run Code Online (Sandbox Code Playgroud) 我正在使用Axis2-1.6.1,并且能够成功发送SOAP请求。这是请求的示例:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="true">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>***username***</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">***pass***</wsse:Password>
<wsse:Nonce Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">***nonce***</wsse:Nonce>
<wsu:Created Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">***datetime***</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
<wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">http://mysite/contract/users/v3/IUsers/EchoAuthenticated</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<ns6:EchoAuthenticated xmlns:ns6="http://mysite/contract/users/v3">
<ns6:value>success</ns6:value>
</ns6:EchoAuthenticated>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
收到响应后,将引发此异常:
org.apache.axis2.AxisFault:必须了解标头http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd的检查失败:安全
经过一些研究后,我的印象是Axis2不喜欢响应。感到困惑的是,我复制了上面的请求并将其粘贴到SoapUI中并解雇了它。它有效,我收到以下回复。我还使用Fiddler确认,这与在Eclipse中发送此请求时得到的响应相同,只是Axis2不喜欢客户端,也许是mustUnderstand?
这是回应:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1">http://mysite/contract/users/v3/IUsers/EchoAuthenticatedResponse</a:Action>
<a:RelatesTo>urn:uuid:***guid***</a:RelatesTo>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="_0">
<u:Created>***datetime***</u:Created>
<u:Expires>***datetime***</u:Expires>
</u:Timestamp>
</o:Security>
</s:Header>
<s:Body>
<EchoAuthenticatedResponse xmlns="http://mysite/contract/users/v3">
<EchoAuthenticatedResult>This is the Users service answering back. The value you sent was: success</EchoAuthenticatedResult>
</EchoAuthenticatedResponse>
</s:Body>
</s:Envelope>
Run Code Online (Sandbox Code Playgroud)
由于与产品捆绑在一起,我只能使用较新版本的Axis2,但我的能力有限,但是我需要找出如何解决此错误的方法。