如何将 FastInfoset 与 JAXWS 结合使用?

发布于 2024-09-02 02:18:29 字数 2083 浏览 2 评论 0原文

根据我能找到的内容,我的代码看起来应该是正确的,但喷出的输出并不表明它正在使用 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 );

日志记录似乎并没有表明 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: 200
Encoding: UTF-8
Content-Type: text/xml; charset=utf-8
Headers: {content-type=[text/xml; charset=utf-8], Content-Length=[611], Server=[Jetty(6.1.x)]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:findContactsResponse>...bunch of xml spew deleted for brevity...</ns1:findContactsResponse></soap:Body></soap:Envelope>
--------------------------------------

你知道我做错了什么吗?即使服务器不支持 FastInfoset,我仍然应该在请求中看到尝试的协商,对吗?

I've got code that looks like it should be correct based on what I can find, but the spewed output doesn't indicate that it's using FastInfoset. My understanding is the Accept should indicate it can accept Fastinfoset and the response would actually use it, meaning it's not text/xml as the response type. Any idea what I'm doing wrong? I've scoured with Google and I'm having a hard time finding much detail on how to use FastInfoset at all.

    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 );

The logging doesn't seem to indicate FastInfoset is even attempted though:

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: 200
Encoding: UTF-8
Content-Type: text/xml; charset=utf-8
Headers: {content-type=[text/xml; charset=utf-8], Content-Length=[611], Server=[Jetty(6.1.x)]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:findContactsResponse>...bunch of xml spew deleted for brevity...</ns1:findContactsResponse></soap:Body></soap:Envelope>
--------------------------------------

Any ideas what I'm doing wrong? Even if the server wasn't supporting FastInfoset, I still should see the attempted negotiation in the request, right?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

红焚 2024-09-09 02:18:29

答案是我所掌握的有关如何启用它的信息已经过时了。以下内容适用于客户端(大概也适用于服务器端,但我已经启用了 Spring 配置来处理它)。

           JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
           // This enables FastInfoset as the communication protocol
           factory.getInInterceptors().add( new FIStaxInInterceptor() );
           factory.getOutInterceptors().add( new FIStaxOutInterceptor() );
           ... other code to set username, location, etc. goes here.
           client = (C360Server) factory.create();

The answer is that the info I had on how to enable it was out of date. The following works on the client end (and presumably server end, but there I've got a Spring configuration enabled that handles it).

           JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
           // This enables FastInfoset as the communication protocol
           factory.getInInterceptors().add( new FIStaxInInterceptor() );
           factory.getOutInterceptors().add( new FIStaxOutInterceptor() );
           ... other code to set username, location, etc. goes here.
           client = (C360Server) factory.create();
吝吻 2024-09-09 02:18:29
//Enabling FastInfoset by configuring proxy 
// Enabling FI in pessimistic mode
Map<String, Object> ctxt = ((BindingProvider)proxy).getRequestContext();
ctxt.put(JAXWSProperties.CONTENT_NEGOTIATION_PROPERTY, "pessimistic");

或者

使用系统属性启用 FastInfoset

-Dcom.sun.xml.ws.client.ContentNegotiation=pessimistic
//Enabling FastInfoset by configuring proxy 
// Enabling FI in pessimistic mode
Map<String, Object> ctxt = ((BindingProvider)proxy).getRequestContext();
ctxt.put(JAXWSProperties.CONTENT_NEGOTIATION_PROPERTY, "pessimistic");

OR

Enabling FastInfoset using system property

-Dcom.sun.xml.ws.client.ContentNegotiation=pessimistic
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文