我正在为 SOAP Web 服务编写客户端。 我正在使用 CXF 库。 使用简单的前端。 以及宙斯盾数据绑定(bind)。 服务器为 Web 方法提供一个 Java 接口(interface)(名为 MediaService),我将该接口(interface)导入到客户端项目中。 然后,我使用 MediaService.aegis.xml 文件为方法参数提供名称(因为它们不被命名以及在序列化请求时)。
这是我在客户端使用的代码:
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setDataBinding(new AegisDatabinding());
factory.setServiceClass(MediaService.class);
factory.setAddress(urlMediaServer);
MediaService service = (MediaService) factory.create();
final List<Reference> listeReferences = service.sendMedia(bu, media);
服务接口(interface)是这样的:
public interface MediaService
{
public List sendMedia(String bu, Media media) throws Exception;
}
我启用了 XML 流日志记录,这样我就可以看到发送到服务器的 XML 流及其返回的流。
这是流:
要求:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:sendMedia xmlns:ns1="http://service.soclemedia.mycompany.com/">
<ns1:bu>sc_phx</ns1:bu>
<ns1:media>
<ns2:productId xmlns:ns2="http://bo.soclemedia.mycompany.com">TEST_CODE</ns2:productId>
<ns2:mediaName xmlns:ns2="http://bo.soclemedia.mycompany.com">test.png</ns2:mediaName>
</ns1:media>
</ns1:sendMedia>
</soap:Body>
</soap:Envelope>
响应:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<sendMediaResponse xmlns="http://service.soclemedia.mycompany.com">
<out xmlns="http://service.soclemedia.mycompany.com">
<ns1:Reference xmlns:ns1="http://bo.soclemedia.mycompany.com">
<subType xmlns="http://bo.soclemedia.mycompany.com">standard</subType>
<typeMedia xmlns="http://bo.soclemedia.mycompany.com">photo</typeMedia>
</ns1:Reference>
<ns1:Reference xmlns:ns1="http://bo.soclemedia.mycompany.com">
<subType xmlns="http://bo.soclemedia.mycompany.com">standard</subType>
<typeMedia xmlns="http://bo.soclemedia.mycompany.com">photo</typeMedia>
</ns1:Reference>
</out>
</sendMediaResponse>
</soap:Body>
</soap:Envelope>
服务被调用,它回复并且客户端收到正确的回复。 但在客户端中,进行 Web 服务调用的行 service.sendMedia(bu, media) 返回 null。 反序列化回复有问题。 您是否知道出了什么问题以及如何解决?
最好的问候。
调用这个方法的时候忘了说:
MediaService service = (MediaService) factory.create();
我收到这个错误:
INFO: Creating Service {http://service.soclemedia.mycompany.com/}MediaService from class com.mycompany.soclemedia.service.MediaService
24 nov. 2011 15:18:37 org.apache.cxf.aegis.type.XMLTypeCreator <clinit>
INFO: Could not set aegis schema. Not validating.
java.lang.UnsupportedOperationException: This parser does not support specification "null" version "null"
at javax.xml.parsers.DocumentBuilderFactory.setSchema(DocumentBuilderFactory.java:489)
at org.apache.cxf.aegis.type.XMLTypeCreator.<clinit>(XMLTypeCreator.java:125)
at org.apache.cxf.aegis.AegisContext.createRootTypeCreator(AegisContext.java:122)
at org.apache.cxf.aegis.AegisContext.createTypeCreator(AegisContext.java:111)
at org.apache.cxf.aegis.AegisContext.initialize(AegisContext.java:153)
at org.apache.cxf.aegis.databinding.AegisDatabinding.initialize(AegisDatabinding.java:229)
at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:438)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:501)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:241)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:153)
...
这是我的 cxf.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
</beans>
这是我的 MediaService.aegis.xml:
<mappings>
<mapping>
<method name="sendMedia">
<parameter index="0" mappedName="bu"/>
<parameter index="1" mappedName="media"/>
<return-type componentType="com.mycompany.soclemedia.bo.Reference" />
</method>
</mapping>
</mappings>
最佳答案
只是一个想法:
在我最近的一个项目中,我发现 CXF web 服务在 Jetty 中本地运行时工作正常,而在 Weblogic 容器中运行时所有顶级集合的反序列化为 null。
显然这是由 JAXB 中的一个已知错误引起的(抱歉,手头没有引用),解决方法是以这种方式包装集合:
public class Wrapper
{
private List<Reference> references;
...
}
并让 web 服务在线上处理这个对象。
我希望这也适用于您的问题,如果运气不好 :-)
/安德斯/
关于java - SOAP 响应在 CXF + 简单前端 + Aegis 数据绑定(bind)中错误地反序列化为 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8254948/
我正在尝试使用ruby和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server
它不等于主线程的binding,这个toplevel作用域是什么?此作用域与主线程中的binding有何不同?>ruby-e'putsTOPLEVEL_BINDING===binding'false 最佳答案 事实是,TOPLEVEL_BINDING始终引用Binding的预定义全局实例,而Kernel#binding创建的新实例>Binding每次封装当前执行上下文。在顶层,它们都包含相同的绑定(bind),但它们不是同一个对象,您无法使用==或===测试它们的绑定(bind)相等性。putsTOPLEVEL_BINDINGput
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file
我克隆了一个rails仓库,我现在正尝试捆绑安装背景:OSXElCapitanruby2.2.3p173(2015-08-18修订版51636)[x86_64-darwin15]rails-v在您的Gemfile中列出的或native可用的任何gem源中找不到gem'pg(>=0)ruby'。运行bundleinstall以安装缺少的gem。bundleinstallFetchinggemmetadatafromhttps://rubygems.org/............Fetchingversionmetadatafromhttps://rubygems.org/...Fe