我很擅长编写Web服务.我正在使用JAXWS开发SOAP服务.我希望能够让用户登录并在我的服务中知道哪个用户正在发出命令.换句话说,有一些会话处理.
我见过这样做的一种方法是使用cookie并从我的Web服务访问HTTP层.但是,这依赖于使用HTTP作为传输层(我知道HTTP几乎总是传输层,但我是纯粹的).
是否有更好的方法可以使服务层不知道传输层?有没有办法用servlet过滤器实现这个目的?我希望答案尽可能与框架无关.
我们已经使用Spring 3.0.5在JBoss 6上运行我们的项目.一切顺利,直到我们尝试使用JAX-WS实现一些Web服务.如果我尝试做一些简单的WS(比如添加2个数字),它就可以了 - 我将注释添加到注释类并添加注释类作为servlet.但是如果我试图让我的JAX-WS类填充依赖项,事情就变得越来越困难.
这是我的代码:
@WebService(name = "principal")
public class PrincipalWebService extends SpringBeanAutowiringSupport {
@Autowired
private PrincipalManager manager;
@WebMethod
public int add(int a, int b) {
return a + b;
}
@WebMethod
public Principal getById(int i) {
return manager.getById(i);
}
}
Run Code Online (Sandbox Code Playgroud)
添加方法有效,但getById因NPE而失败.我一直在调试SpringBeanAutowiringSupport,它看起来像ContextLoader.getCurrentWebApplicationContext()返回null.这意味着在初始化上下文之前调用SpringBeanAutowiringSupport构造函数.
我一直在尝试使用Spring运行应用程序的CXF说明.我现在没有这个代码,但是我已经将PrincipalWebService注册为bean,创建了spring文件来配置CXF并通过它的ID作为端点添加了这个bean.它在Jetty上表现不错,但在JBoss上失败了.我一直在接收不同类型的异常,具体取决于我如何配置CXF,但根本原因是相同的 - JBoss 6 CXF版本是针对Spring 2.5编译的,所以我们有库不一致.
有没有人有任何想法让IoC为JBoss 6上的Jax-ws服务工作?
我开始使用WSDL并使用wsimport生成Java artificats.然后我实现了WebService并将其部署到glassfish 3.1.glassfish获取java元素并从这些元素中重新生成wsdl.
我可以说服glassfish将原始的wsdl发布到世界上,而不是"重新设计"的那些吗?谢谢!
我有一个调用第三方Web服务的Web服务.
现在我想对我的网络服务进行单元测试.为此,我应该模拟第三方Web服务还是在测试期间调用它?
是否有关于单元测试的标准文件?
Apache CFX可以完成任务.但是我想在没有任何弹簧的情况下将它结合起来.谢谢你提前!
我从Android客户端连接到我的webservice时遇到问题.在我的MainActivity类中,程序在该行崩溃:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
Run Code Online (Sandbox Code Playgroud)
问题是定义不是方法名称,而是关于命名空间的东西,但我不知道有什么问题.
GameAndroidUtil:
private static final String NAMESPACE = "http://game.webcentral.pl/";
private static final String SOAP_ACTION = "";
private static final String WSDL_URL = "http://localhost:8080/ReversiGameWS/services/GameWS?wsdl";
Run Code Online (Sandbox Code Playgroud)
主要活动:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
GameAndroidUtil.testGameWS();
} catch (SoapFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
我的GameWS.wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://game.webcentral.pl" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://game.webcentral.pl" xmlns:intf="http://game.webcentral.pl" xmlns:tns1="http://data.game.webcentral.pl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 …Run Code Online (Sandbox Code Playgroud) 我在使用Glassfish应用程序服务器运行JAX_WS Webservices时遇到问题.以前,我曾经使用Apache tomcat,它可以很好地工作.但是现在,有了Glassfish,这个问题阻止了应用程序的部署...请在下面查看:
2013-04-04T13:09:23.028+0300 com.sun.xml.ws.wspolicy.com.sun.xml.ws.api.policy.ModelTranslator
SEVERE: [failed to localize] WSP_0071_ERROR_MULTIPLE_ASSERTION_CREATORS_FOR_NAMESPACE(http://schemas.xmlsoap.org/ws/2004/08/addressing, com.sun.xml.ws.security.addressing.impl.policy.AddressingPolicyAssertionCreator, com.sun.xml.ws.addressing.impl.policy.AddressingPolicyAssertionCreator)
2013-04-04T13:09:23.028+0300 com.sun.xml.ws.wspolicy.jaxws.PolicyWSDLParserExtension
SEVERE: [failed to localize] WSP_0071_ERROR_MULTIPLE_ASSERTION_CREATORS_FOR_NAMESPACE(http://schemas.xmlsoap.org/ws/2004/08/addressing, com.sun.xml.ws.security.addressing.impl.policy.AddressingPolicyAssertionCreator, com.sun.xml.ws.addressing.impl.policy.AddressingPolicyAssertionCreator)
2013-04-04T13:09:23.028+0300 com.sun.xml.ws.wspolicy.jaxws.PolicyWSDLParserExtension
SEVERE: WSP1007: Policy exception occurred when finishing WSDL parsing.
com.sun.xml.ws.policy.PolicyException: [failed to localize] WSP_0071_ERROR_MULTIPLE_ASSERTION_CREATORS_FOR_NAMESPACE(http://schemas.xmlsoap.org/ws/2004/08/addressing, com.sun.xml.ws.security.addressing.impl.policy.AddressingPolicyAssertionCreator, com.sun.xml.ws.addressing.impl.policy.AddressingPolicyAssertionCreator)
at com.sun.xml.ws.policy.sourcemodel.PolicyModelTranslator.<init>(PolicyModelTranslator.java:188)
at com.sun.xml.ws.api.policy.ModelTranslator.<init>(ModelTranslator.java:85)
at com.sun.xml.ws.api.policy.ModelTranslator.<clinit>(ModelTranslator.java:74)
at com.sun.xml.ws.policy.jaxws.BuilderHandler.getPolicies(BuilderHandler.java:102)
at com.sun.xml.ws.policy.jaxws.BuilderHandler.getPolicySubjects(BuilderHandler.java:110)
at com.sun.xml.ws.policy.jaxws.BuilderHandlerEndpointScope.doPopulate(BuilderHandlerEndpointScope.java:72)
at com.sun.xml.ws.policy.jaxws.BuilderHandler.populate(BuilderHandler.java:82)
at com.sun.xml.ws.policy.jaxws.PolicyMapBuilder.getNewPolicyMap(PolicyMapBuilder.java:109)
at com.sun.xml.ws.policy.jaxws.PolicyMapBuilder.getPolicyMap(PolicyMapBuilder.java:91)
at com.sun.xml.ws.policy.jaxws.PolicyWSDLParserExtension.postFinished(PolicyWSDLParserExtension.java:960)
at com.sun.xml.ws.wsdl.parser.DelegatingParserExtension.postFinished(DelegatingParserExtension.java:191)
at com.sun.xml.ws.wsdl.parser.WSDLParserExtensionFacade.postFinished(WSDLParserExtensionFacade.java:338)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:234)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:191)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:160)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:307)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:269)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:205)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:195)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:112)
at …Run Code Online (Sandbox Code Playgroud) 我的问题是我有一个MessageList类,它包含Message项,定义如下:
<xsd:complexType name="MessageType">
<xsd:sequence>
<xsd:any/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Message" type="tns:MessageType"/>
<xsd:complexType name="MessageListType">
<xsd:sequence>
<xsd:element name="Message" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="MessageList" type="tns:MessageListType"/>
Run Code Online (Sandbox Code Playgroud)
我的消息类看起来像(我在这里省略了getter和setter)
public class Message
{
private String referenceId;
private String messageType;
private Timestamp createdTime;
private String transactionIdForeignKey;
private String xmlDetail;
}
Run Code Online (Sandbox Code Playgroud)
当我尝试在我的servlet中封送这个类时,如:
List<Message> retrievedMessages = new ArrayList<Message>();
retrievedMessages.add(new Message);
retrievedMessages.add(new Message);
MessageListType messageListType = new MessageListType();
for(Message message: retrievedMessages){
messageListType.getMessage().add(message);
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
[#|2013-04-25T16:43:40.434+0100|WARNING|sun-appserver2.1|javax.enterprise.system.stream.err|_ThreadID=188;_ThreadName=p: thread-pool-1; w: 76;_RequestID=40c6fe10-c12f-4d0b-8912-c960381910d7;|
javax.xml.ws.WebServiceException: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: class uk.co.test.test.audit.model.Message nor any of its …Run Code Online (Sandbox Code Playgroud) 我已经通过RAD(eclipse)创建了一个JaX Webservice,我可以使用@WebParam注释和我的函数参数,但我也想使用@webresult等但不知道我应该在哪里指定它们,在google I有接口,但在这里我只有类和委托类.
我的班级是
public class GetFPDDataClass {
public String GetFPDDataInput(String PolicyNumber)
{
return PolicyNumber;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的委托班
@WebService (targetNamespace="fpd", serviceName="GetFPDDataClassService", portName="GetFPDDataClassPort")
public class GetFPDDataClassDelegate{
fpd.GetFPDDataClass _getFPDDataClass = null;
public String GetFPDDataInput (@WebParam(name="PolicyNumber") String PolicyNumber) {
return _getFPDDataClass.GetFPDDataInput(PolicyNumber);
}
public GetFPDDataClassDelegate() {
_getFPDDataClass = new fpd.GetFPDDataClass(); }
}
Run Code Online (Sandbox Code Playgroud) jax-ws ×10
web-services ×6
java ×5
glassfish-3 ×2
android ×1
cxf ×1
eclipse ×1
glassfish ×1
jax-rs ×1
jboss6.x ×1
marshalling ×1
myeclipse ×1
rad ×1
session ×1
soap ×1
spring ×1
unit-testing ×1
wsdl ×1
wsgen ×1
xsd ×1