我有一个带有方法签名的Web服务,如下所示:
public RetType doIt(String description){
return null;
}
Run Code Online (Sandbox Code Playgroud)
在生成wsdl之后,我看到(在wsdl中)方法doIt有参数名称arg0.在代码优先方法中是否有一种方法可以像在Java类方法签名中那样在wsdl中指定参数名称?
我正在寻找可以在OSGi容器内运行并使用SOAP连接到简单Web服务的任何webservice客户端,听起来不是那么难吗?
哦,它必须在Java 1.5下工作,所以JRE jax-ws不会出现.
问题是我现在已经尝试了一些解决方案,尽管每个解决方案都在标准Java中使用,但在OSGi中使用它却没有.
是否有人成功创建了OSGi Web服务客户端?
我有一个通过SOAP进行通信的客户端/服务器应用程序.服务器端应用程序是一个Java EE应用程序,它使用JAX-WS公开Web服务.我有一个servlet过滤器设置来在调用服务之前执行某些检查.
除异常处理外,这一切都运行良好.如果我从过滤器中抛出异常,它将作为通用服务器异常返回到客户端.我需要找到一种方法来传播包含特定消息的自定义异常,以便客户端可以向用户显示消息.
任何见解?
我有一个Servlet容器(Glassfish/OC4J),它为一些可以使用HTTPS访问的JAX-WS Web服务端点提供服务.SSL配置为支持客户端身份验证和仅服务器身份验证(如Glassfish上的client-auth ="want").
在我的端点实现中,我想知道连接是否使用客户端身份验证完成.我已经有了访问该HttpServletRequest对象的权限,但是该getAuthType()方法总是返回null,如果Client auth完成则不会返回null(使用wireshark检查以确保它符合我的要求).
有谁知道如何访问这些信息?
非常感谢
如何从JAX-WS Web服务获取经过身份验证的用户信息?
谢谢
我想为我的jax-ws webservice启用http压缩.我发现我必须使用可以修改http标头的自定义处理程序链.
我找到的所有教程都引用了注释@HandlerChain,指向处理程序链配置xml文件但我的问题是我的webservice必须尽可能轻量级,因此我无法在外部xml文件中定义我的处理程序链.
我尝试了以下但没有成功:
final Endpoint ep = Endpoint.publish("http://localhost:8878/mywebservice",
new WebserviceImpl() );
final Binding binding = ep.getBinding();
final List<Handler> handlerChain = binding.getHandlerChain();
handlerChain.add(new MySuperbSOAPHandler());
binding.setHandlerChain(handlerChain);
Run Code Online (Sandbox Code Playgroud)
有谁知道如何做到这一点?它甚至可能吗?
我正在尝试访问我正在处理的项目的Web服务.我正在使用JAX-WS,应用程序部署在weblogic上.当我试图访问WS时,我得到以下异常:
javax.portlet.PortletException: javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://xxx.xxxx.ro:40000/idm/ws/cup?wsdl. It failed with:
Response: '401: Unauthorized' for url: 'http://xxx.xxxx.ro:40000/idm/ws/cup?wsdl'.
at com.bea.portlet.container.PortletStub.processAction(PortletStub.java:346)
at com.bea.portlet.container.AppContainer.invokeProcessAction(AppContainer.java:678)
........
Run Code Online (Sandbox Code Playgroud)
我阅读了很多关于问题的帖子,我尝试了不同类型的auth.我尝试在不同的用例中使用BindingProvider,basicHTTPAuth,禁用HostnameVerifier等但仍然没有结果.
以下是我的代码片段,作为最后一个尝试过的版本:
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
username,
password.toCharArray());
}
});
ComputeUserProfileImplService computeUserProfileImplService = new ComputeUserProfileImplService(
new URL(null, endpointURL, new sun.net.www.protocol.http.Handler()),
new QName("http://xxx.xx.xxxxx.xxxxx.com/",
"ComputeUserProfileImplService"));
ComputeUserProfileImpl computeUserProfile = computeUserProfileImplService
.getComputeUserProfileImplPort();
Run Code Online (Sandbox Code Playgroud)
ComputeUserProfileImplService代码如下所示:
private final static URL COMPUTEUSERPROFILEIMPLSERVICE_WSDL_LOCATION;
private final static Logger logger = Logger.getLogger(com.xxxxx.xxxxx.xx.xxxxx.cup.ComputeUserProfileImplService.class.getName());
static {
URL url = null;
try { …Run Code Online (Sandbox Code Playgroud) 我创建了一个SOAP拦截器,如CXF文档中所述:
public class SoapMessageInterceptor extends AbstractSoapInterceptor {
public SoapMessageInterceptor() {
super(Phase.USER_PROTOCOL);
}
public void handleMessage(SoapMessage soapMessage) throws Fault {
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
并在Spring的应用程序上下文中将其注册到总线:
<cxf:bus>
<cxf:inInterceptors>
<ref bean="soapMessageInterceptor"/>
</cxf:inInterceptors>
</cxf:bus>
<jaxws:endpoint id="customerWebServiceSoap"
implementor="#customerWebServiceSoapEndpoint"
address="/customerService"/>
Run Code Online (Sandbox Code Playgroud)
一切正常,直到我添加了REST服务:
<jaxrs:server id="customerWebServiceRest" address="/rest">
<jaxrs:serviceBeans>
<ref bean="customerWebServiceRestEndpoint" />
</jaxrs:serviceBeans>
</jaxrs:server>
Run Code Online (Sandbox Code Playgroud)
问题是SOAP拦截器现在也在REST请求上被触发,这导致在调用REST服务时出现类强制转换异常.
<ns1:XMLFault xmlns:ns1="http://cxf.apache.org/bindings/xformat">
<ns1:faultstring xmlns:ns1="http://cxf.apache.org/bindings/xformat">
java.lang.ClassCastException: org.apache.cxf.message.XMLMessage
cannot be cast to org.apache.cxf.binding.soap.SoapMessage
</ns1:faultstring>
</ns1:XMLFault>
Run Code Online (Sandbox Code Playgroud)
有没有办法只通过配置将拦截器限制为SOAP消息?
更新
看起来我错过了描述这个的文档中的页面.向下滚动到JAXRS过滤器和CXF拦截器之间的差异
我有一个SOAP Web服务.
从SoapUI调用它时,无论消息内容的大小如何,请求都能正常工作.
如果我从Apache CXF客户端代码发出相同的请求,它可以处理小请求,但如果我的消息内容太长,我会得到"连接重置",但有以下异常:
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at com.sun.net.ssl.internal.ssl.InputRecord.readFully(Unknown Source)
at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.AppInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1606)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1532)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1440)
... 37 more
Run Code Online (Sandbox Code Playgroud)
有什么可能导致它或如何调试它的想法?
在CXF SOAP Web服务中,我使用以下注释来禁用xsd验证:
@EndpointProperties({
@EndpointProperty(key = "set-jaxb-validation-event-handler", value = "false")
})
Run Code Online (Sandbox Code Playgroud)
我希望在运行时控制验证(根据从数据库检索的设置的值启用/禁用它).我的问题是:是否可以在运行时禁用/启用此处理程序?也许通过编写自定义事件处理程序而根本不使用此属性?
谢谢.
编辑:一个选项不是禁用验证set-jaxb-validation-handler,而是子类ValidationEventHandler.正如解释在这里,我会再检查数据库设定handleEvent,并根据其价值回归.
但是这种方法仍有一些缺点:首先,这个web服务配置了注释,我似乎无法找到一种方法来应用ValidationEventHandler带注释(同样的问题:如何在使用时在JAXB unmarshaller上设置自定义ValidationEventHandler注释).
其次,这意味着即使我不需要验证也会执行; 然后我将失去任何性能优势.
它实际上并不完全符合我的需要,所以我仍然愿意接受任何建议.