我尝试向我的Apache CXF 3客户端 API添加代理。
ClientBuilder.newClient().target(serverUri)
.request()
.post();
Run Code Online (Sandbox Code Playgroud)
在 Jersey 实现中,我使用 ClientConfig :
ClientConfig config = new ClientConfig();
config.connectorProvider(new ApacheConnectorProvider());
config.property(ClientProperties.PROXY_URI, proxyAddress);
ClientBuilder.newClient(config) ...
Run Code Online (Sandbox Code Playgroud)
我想用 CXF 3 做同样的事情而不使用他们的特定客户端(我使用 JAX-RS 客户端实现)并且不在 JVM 上设置代理。
任何帮助都将得到回报 ;)
编辑 :
解决方案的开始可以是:
client.property("http.proxy.server.uri", proxyUri);
client.property("http.proxy.server.port",proxyPort);
Run Code Online (Sandbox Code Playgroud)
但我没有找到代理身份验证的属性。
在尝试使用 apache cxf 3.1.6 和 java 8 使用 SOAP 服务时,通过更改有效负载内容,我得到了“200 OK”或“403 Forbidden”。
奇怪的是,如果我打印出有效负载并放在 SOAPUI 上,那么我总是得到 200 OK。
你遇到过类似的问题吗?如何解决这个问题?
我想将 RESTEasy 与部署到 TomEE 的 web 应用程序一起使用。如何禁用 CXF,使其不会尝试启动 REST 服务?
我编写了一个类扩展 ContainerRequestFilter 以进行权限检查。如何获取匹配方法的注释以进行权限检查。
@javax.ws.rs.ext.Provider
public class AuthorizationRequestFilter implements ContainerRequestFilter {
public void filter(ContainerRequestContext requestContext) throws IOException {
// how can I get resources' methods' annotation here?
// from the resource below , I want to checkout whether the target matched method contains the @ReadPermission annotation
}
}
@Path("/region")
public class Region {
@POST
@Path("/{region_id}")
@Produces({MediaType.APPLICATION_JSON , MediaType.APPLICATION_XML})
@ReadPermission
public String getRegion() {
return null;
}
}
Run Code Online (Sandbox Code Playgroud) 如何在 Web 服务客户端请求上添加如下 XML 所示的标头?
下面的 xml 是由 SOAP UI 自动生成的请求,只要提供正确的用户名/密码,它就可以正常工作。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dof="http://dof.ad.com">
<soapenv:Header>
<dof:UserCredentials>
<!--Optional:-->
<dof:userName></dof:userName>
<!--Optional:-->
<dof:password></dof:password>
</dof:UserCredentials>
</soapenv:Header>
<soapenv:Body>
<dof:CheckService/>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
我想知道如何使用 apache CXF 添加标头部分。我已经使用 WSDL 中的 CXF 自动生成了代码(见下文)并检查了各种文章,但代码仍然无法正常工作。我假设发送的请求不正确或者没有标头。
public static void checkServiceMan() {
String address = "https://WSDL_URL";
JaxWsProxyFactoryBean jaxWsProxy = new JaxWsProxyFactoryBean();
jaxWsProxy.setServiceClass(DOFairservice.class);
jaxWsProxy.setAddress(address);
DOFairservice serviceClient = (DOFairservice) jaxWsProxy.create();
ObjectFactory factory = new ObjectFactory();
UserCredentials uc = factory.createUserCredentials();
uc.setUserName("username");
uc.setPassword("password");
List<Header> headerList = new ArrayList<Header>();
try {
Header testCredentialsHeader = new Header(new QName("http://DOF", "DOFairservice") …
Run Code Online (Sandbox Code Playgroud) 我部署了一个 Spring 微服务 docker。我使用 JaxWsProxyFactoryBean 调用外部服务器 (soap/wsdl),并且使用 http://externalServer 一切顺利:
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
jaxWsProxyFactoryBean.setAddress("http://externalServer");
...
Run Code Online (Sandbox Code Playgroud)
当我在 setAddress 中调用 https 时,问题就出现了。
我使用 keytool 在密钥库中注册了被调用服务器的密钥/证书,并将其保存到 /root/.keystore (标准),并从 pfx 导入它。当我尝试调用 https 时,出现此错误:
org.apache.cxf.transport.https.SSLUtils : Default key managers cannot be initialized: Password must not be null
Run Code Online (Sandbox Code Playgroud)
好的,我缺少密码。但是这个恶意密码放在哪里呢?在application.yml中?在系统属性中?[keystore中使用的密码是标准的(changeit)]
编辑
这是日志的快照:
DEBUG 1 --- [ XNIO-1 task-1] org.apache.cxf.transport.https.SSLUtils : The location of the key store has not been set via a system parameter or through configuration so the default value of /root/.keystore will be used. …
Run Code Online (Sandbox Code Playgroud) 在使用CXF建立合同第一组Web服务之前我做得非常好,直到我开始添加WSS4J部分.
我正在尝试调试发送密码并登录soap标头.当我在WSPasswordCallback类中调用getPassword()时,我得到null.我可以从肥皂信封中看到发送了密码.
这篇文章http://old.nabble.com/PasswordDigest-and-PasswordText-difference-td24475866.html,从2009年开始,让我想知道我是否缺少(需要创建)UsernameTokenHandler.
如果这是真的,有人可以指出我如何在spring/cxf bean xml文件中配置它?
任何建议或意见将不胜感激.
这是有问题的Java文件:
package com.netcentric.security.handlers;
import java.io.IOException;
import javax.annotation.Resource;
import javax.com.urity.auth.callback.Callback;
import javax.com.urity.auth.callback.CallbackHandler;
import javax.com.urity.auth.callback.UnsupportedCallbackException;
import org.apache.ws.com.urity.WSPasswordCallback;
public class ServicePWCallback implements CallbackHandler
{
@Override
public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
try {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof WSPasswordCallback) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
sString login = pc.getIdentifier();
String password = pc.getPassword();
// password is null, not the expected myPASSWORD**1234
int n = …
Run Code Online (Sandbox Code Playgroud) 我使用在Tomcat7上运行的Eclipse构建了一个CXF + Spring Web服务.Web服务工作,但它不会从我的一个类创建复杂类型.
我的Eclipse项目叫做:"ws-server".在构建路径中,我添加了API-A,API-A-Impl和API-B.
构建路径是正确的.所有库都按照应有的方式进行部署.wsdl已创建,但API-B中没有复杂类型(API-B中只有一个类,Page).
在wsdl中,Page类在其他复杂类型中定义如下.
<xs:complexType name="getAllMeasuremenetObjectsByPage">
<xs:sequence>
<xs:element minOccurs="0" name="page"/>
<xs:element minOccurs="0" name="orderBy" type="xs:string"/>
<xs:element minOccurs="0" name="orderDirection" type="tns:orderDirection"/>
</xs:sequence>
</xs:complexType>
Run Code Online (Sandbox Code Playgroud)
我不知道从哪里开始寻找.感觉CXF有什么东西.我认为Eclipse项目配置没有任何问题.Web服务中没有"page"参数的所有其他方法都有效.
请建议Apache CXF Web服务框架的在线教程.我是初学者,只掌握Java EE(JSP,Servlets,HTML,CSS,JavaScript,JQuery)的基本知识,并且知道一点点休眠.我也熟悉JDBC.
如果有任何可用于Eclipse Indigo IDE的CXF插件,请告诉我.
在尝试从提供的WSDL开发WS客户端几天之后,我发现我一直都在使用轴,而不是轴2 ......
好吧,我正在做的是右键单击wsdl> New> Other> Web Service Client.
在向导窗口中,'Web服务运行时'一直设置为'Apache Axis',我没有看到.单击它我可以选择'Apache Axis2'和'Apache CXF 2.x',但两者都失败,而'Apache Axis'"工作":客户端已创建,但不会向XML添加头用户名和密码请求.
这是我在尝试使用CXF时遇到的错误:
Unable to add the follwing facets to project SIAPP_WS_FORNECEDOR_CFX_01: CXF 2.x Web Services.
org.eclipse.wst.common.project.facet.core.FacetedProjectFrameworkException: Failed while installing CXF 2.x Web Services 1.0.
at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.callDelegate(FacetedProject.java:1507)
at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.modifyInternal(FacetedProject.java:441)
at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.mergeChangesInternal(FacetedProject.java:1181)
at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.access$2(FacetedProject.java:1117)
at org.eclipse.wst.common.project.facet.core.internal.FacetedProject$1.run(FacetedProject.java:324)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.modify(FacetedProject.java:339)
at org.eclipse.jst.ws.internal.consumption.ui.common.FacetOperationDelegate$1.run(FacetOperationDelegate.java:62)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: org.eclipse.core.runtime.CoreException: CXF Runtime location not set. Please set location in Preferences > Web Services > CXf 2.x Preferences
at org.eclipse.jst.ws.internal.cxf.facet.CXFFacetInstallDelegate.execute(CXFFacetInstallDelegate.java:50)
at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.callDelegate(FacetedProject.java:1477)
... …
Run Code Online (Sandbox Code Playgroud) cxf ×10
java ×5
jax-rs ×2
rest ×2
soap ×2
spring ×2
web-services ×2
apache ×1
apache-tomee ×1
axis ×1
docker ×1
eclipse-wtp ×1
keytool ×1
permissions ×1
proxy ×1
resteasy ×1
ssl ×1
tomee-7 ×1
wss4j ×1