标签: jax-ws

如何在JAXWS中使用FastInfoset?

根据我能找到的内容,我的代码看起来应该是正确的,但是输出的代码并不表示它正在使用FastInfoset.我的理解是Accept应该表明它可以接受Fastinfoset并且响应实际上会使用它,这意味着它不是text/xml作为响应类型.知道我做错了什么吗?我和Google一起搜索过,我很难找到有关如何使用FastInfoset的详细信息.

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.getInInterceptors().add(new LoggingInInterceptor());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    factory.setServiceClass( C360Server.class);
    factory.setAddress("http://localhost:8501/cxfcontroller/cl_v5");
    C360Server client = (C360Server)factory.create();
    ((BindingProvider)client).getRequestContext().put(
        "com.sun.xml.ws.client.ContentNegotiation", "optimistic");

    C360Request requestTrans = new C360Request();
    ... code to fill in the request ...
    C360Response response = client.findContacts( requestTrans );
Run Code Online (Sandbox Code Playgroud)

记录似乎并不表示FastInfoset甚至尝试过:

INFO: Outbound Message
---------------------------
ID: 1
Address: http://localhost:8501/cxfcontroller/cl_v5
Encoding: UTF-8
Content-Type: text/xml
Headers: {SOAPAction=[""], Authorization=[Basic cWFfc3VwZXI6cWFfc3VwZXI=], Accept=[*/*]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:findContacts>...bunch of xml deleted for brevity...</ns1:findContacts></soap:Body></soap:Envelope>
--------------------------------------
May 17, 2010 3:23:45 PM org.apache.cxf.interceptor.LoggingInInterceptor logging
INFO: Inbound Message
----------------------------
ID: 1
Response-Code: …
Run Code Online (Sandbox Code Playgroud)

java jax-ws fastinfoset

4
推荐指数
1
解决办法
2515
查看次数

sun-jaxws.xml中的JAX-WS多端点

刚开始使用JAX-WS.我在一个WAR文件中创建了2个测试Web服务,如下所示....

package com.djs;

import javax.jws.WebService;

@WebService()
public class AddTwoInts {

    public int performAdd(int firstNum, int secondNum) {
        return firstNum + secondNum;
    }
}
Run Code Online (Sandbox Code Playgroud)

和.....

package com.djs;

import javax.jws.WebService;

@WebService()
public class SayHello {

    public String sayHello(String inwards) {
        return "Hello " + inwards;
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
                             http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

    <listener>
        <listener-class>
            com.sun.xml.ws.transport.http.servlet.WSServletContextListener
        </listener-class>
    </listener>

    <servlet>
        <servlet-name>jaxws</servlet-name>
        <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>jaxws</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>
Run Code Online (Sandbox Code Playgroud)

这是sun-jaxws.xml

<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>  
    <endpoint name='performAdd' implementation='com.djs.AddTwoInts' url-pattern='/AddTwoInts' …
Run Code Online (Sandbox Code Playgroud)

java web-services jax-ws

4
推荐指数
1
解决办法
2万
查看次数

如何在JAXB中调试编组?

在编组期间,我得到了下一个例外

Exception in thread "main" com.sun.xml.internal.ws.encoding.soap.DeserializationException: Failed to read a response: javax.xml.bind.UnmarshalException
 - with linked exception:
[javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1127]
Message: XML document structures must start and end within the same entity.]
Run Code Online (Sandbox Code Playgroud)

所以我想看看[行,col]:[1,1127]所在的xml.请建议.

java jax-ws jaxb unmarshalling

4
推荐指数
2
解决办法
2万
查看次数

在jax-ws/wsimport中的cdata

我使用wsimport创建了一个soap客户端,我需要将消息中字符串字段内的xml数据发送到Web服务器.我知道我不需要在webservice调用中使用cdata,但webservice需要这个字段在cdata标签中.

问题是如何做到这一点.

要从wsdl生成代码,我使用jaxws-maven-plugin.在maven配置中我使用绑定文件

bindingFiles
   binding Filebinding.xjb /bindingFile
/bindingFiles
Run Code Online (Sandbox Code Playgroud)
jxb:bindings version="2.0"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:tns="urn:uniface:applic:services:BRF_IN"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb">

    <jxb:globalBindings generateElementProperty="false"/>
    <jxb:bindings scd="//element::tns:DATA">
        <jxb:javaType 
                name="String"                          
                parseMethod="de.xyz.CdataConverter.unmarshal"                      
                printMethod="de.xyz.CdataConverter.marshal"
                />
    </jxb:bindings>
Run Code Online (Sandbox Code Playgroud)

和marshal/unmarschal看起来像这样:

public class CdataConverter {
private static final Pattern PATTERN = Pattern.compile("((?<=\\<\\!\\[CDATA\\[)[\\S\\s]+(?=\\]\\]\\>))");
private static final String CDATA_START = "<![CDATA[";
private static final String CDATA_END = "]]>";
private final static Logger logger =    

Logger.getLogger(LgTestServer.class.getName());

public static String marshal(String input) {
    if (input == null) {
        return null;
    }
    PropertyConfigurator.configure(".\\log4j.properties");
    logger.info("input --------------------->>>>>>>>\n" + input);
    return CDATA_START + input + …
Run Code Online (Sandbox Code Playgroud)

jax-ws cdata wsimport

4
推荐指数
1
解决办法
5120
查看次数

如何告诉wsimport使用代理例外URL

我需要连接到内部Intranet Web服务.我公司使用代理服务器访问互联网,但内部网站点不通过代理.我可以在IE和Firefox中导航到WSDL,但我必须在两个浏览器中将地址添加到代理例外列表中.

当我使用wsimport时,由于代理服务器,我无法获得WSDL.添加或删除-httpproxy arg给我一个错误"无法通过代理隧道"所以我猜这不是我需要这样做的方式.

有没有人知道我可以告诉wsimport忽略这个网址的代理服务器?

尼尔

java wsdl web-services jax-ws wsimport

4
推荐指数
1
解决办法
9067
查看次数

生成的WSDL中的空soapAction

我正在尝试使用JAX-WS从我的Java代码生成WSDL.

一切似乎都运行正常,除了对于我在WSDL中的操作,soapAction仍然是空的.

这是我的代码:

@WebService
public class MyClass {
    public MyStuff queryStuff(String myParam) {
        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

生成的WSDL包含:

<wsdl:operation name="queryStuff">
    <wsdlsoap:operation soapAction=""/>
    <wsdl:input name="queryStuffRequest">
        <wsdlsoap:body use="literal"/>
    </wsdl:input>
    <wsdl:output name="queryStuffResponse">
        <wsdlsoap:body use="literal"/>
    </wsdl:output>
</wsdl:operation>
Run Code Online (Sandbox Code Playgroud)

我不知道我做错了什么.有任何想法吗?

java soap web-services jax-ws

4
推荐指数
1
解决办法
1万
查看次数

Java 5上的JAX-WS RI

首先,根据文档,JAX-WS参考实现应该与Java 5一起使用.

但是,使用最新版本(2.2.7)的二进制包使用Java 6(类版本50.0)进行编译,因此将其与Java 5一起使用将导致抛出UnsupportedClassVersionError.我已经下载了Java源代码并尝试使用Java 5编译它们,但由于依赖库是为Java 6编译的,因此它也无法直接工作.我已经尝试使用"-target 1.5"编译Java 6的新版本,以至少在编译的文件中获得正确的类版本,但我不确定是否遇到其他问题,如果实际在某些时候执行期望Java 6或更新版本.

有没有人知道最新的JAX-WS RI版本,已知可以与Java 5一起使用而没有类似的解决方法?


编辑:

为了回答我的问题的至少一部分,JAX-WS RI实现利用Java 6 SE API中的新功能,并且不会在Java 5上运行,即使这些类是针对目标1.5编译的.至少类org.jvnet.ws.message.BasePropertySet使用类java.util.AbstractMap $ SimpleImmutableEntry,它仅在Java 1.6之后可用.

java jax-ws java-5

4
推荐指数
1
解决办法
2775
查看次数

JAX-WS Web方法中的自定义线程

我通过JAX-WS遇到Web服务问题.如果我在web方法中启动线程,它将在与客户端的连接结束时结束.

例:

@WebMethod(operationName="test")
public boolean test()
{
  Thread th = new MyThread();
  th.start();
  // Thread is running
  ...
  return true;
  // Now thread th ends;
}
Run Code Online (Sandbox Code Playgroud)

有没有解决方案让线程运行?

java multithreading jax-ws

4
推荐指数
1
解决办法
362
查看次数

应用程序主要用于JAX-RS Web服务

我目前正在实现我的第一个基于JAX-RS的REST服务,在我对JAX-RS的研究中,我发现了两个版本如何实现应用程序的主要"入口点".一种选择是实现一个在其main方法中启动服务器的类:

public class Spozz {
    public static void main(String[] args) throws Exception {
        //String webappDirLocation = "src/main/webapp/";
        int port = Integer.parseInt(System.getProperty("port", "8087"));
        Server server = new Server(port);

        ProtectionDomain domain = Spozz.class
                .getProtectionDomain();
        URL location = domain.getCodeSource().getLocation();

        WebAppContext webapp = new WebAppContext();
        webapp.setContextPath("/");
        webapp.setDescriptor(location.toExternalForm() + "/WEB-INF/web.xml");
        webapp.setResourceBase(location.toExternalForm());
        webapp.setServer(server);
        webapp.setWar(location.toExternalForm());

        webapp.setParentLoaderPriority(true);

        // (Optional) Set the directory the war will extract to.
        // If not set, java.io.tmpdir will be used, which can cause problems
        // if the temp directory gets cleaned periodically.
        // …
Run Code Online (Sandbox Code Playgroud)

java rest web-services jax-ws

4
推荐指数
1
解决办法
1210
查看次数

Wildfly的JAXWS实现似乎忽略了bindingProvider属性com.sun.xml.ws.transport.https.client.SSLSocketFactory

我的环境是Maven Project和Wildfly(8.2.1)作为Application Server.我需要的是使用SOAP将传入的REST调用连接到第三方服务器.我需要SSL客户端身份验证; 因此,我有自己的KeyStore和TrustStore.因此,我创建了自己的SSLContext,并且需要让WebService使用此SSLContext.

Wildfly有一个问题,它使用了JAXWS(Apache CXF?)的实现 - 我在这里描述它(但是用另一个方法来解决问题;因此它不是一个重复的帖子!):
Wildfly:如何使用JAXWS-RI而不是Apache CXF(仅限WebService客户端)

其中一个主要问题似乎是Wildfly中使用的JAXWS似乎忽略了使用属性设置自己的SSLContext com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory:

MyWS_Service service = new MyWS_Service(null, new QName("http://...", "MyWS"));
MyWS port = service.getMyWSSOAP();

BindingProvider bindingProvider = (BindingProvider) port;
bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://hostname:443/.../...");

// the following setting is ignored!
bindingProvider.getRequestContext().put("com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory", mySslSocketFactory);

// in some posts, we see that we need to eliminate 'internal' in the property. This does not help!
bindingProvider.getRequestContext().put("com.sun.xml.ws.transport.https.client.SSLSocketFactory", mySslSocketFactory);
Run Code Online (Sandbox Code Playgroud)

它被忽略的证据是,如果我HttpsURLConnection.setDefaultSSLSocketFactory(mySslSocketFactory)用来设置SSLContext,它确实有效 - 意味着SSL连接已建立,这要归功于导入的根CA到SSLContext中自定义的TrustStore设置.

如果我们查看其他帖子(例如,如何以编程方式设置JAX-WS客户端的SSLContext?),这个属性应该可以工作(即使对Wildfly也有一些评论).但它不适合我的情况.这可能是什么原因?

java ssl soap jax-ws wildfly

4
推荐指数
2
解决办法
3889
查看次数