我使用部署在 WebLogic 10.3 上的 JAX-WS (v2.1.3 - Sun JDK 1.6.0_05) 开发了一个 Web 服务,当我使用 Java 客户端或 SoapUI 或其他 Web 服务测试工具时,它工作得很好。我需要使用 2005 Microsoft SQL Server Reporting Services 使用此服务,但出现以下错误
由于异常,无法创建 SOAP 消息:XML 阅读器错误:意外的字符内容
SEVERE: Couldn't create SOAP message due to exception: XML reader error: unexpected character content: "?"
com.sun.xml.ws.protocol.soap.MessageCreationException: Couldn't create SOAP message due to exception: XML reader error: unexpected character content: "?"
at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:292)
at com.sun.xml.ws.transport.http.HttpAdapter.decodePacket(HttpAdapter.java:276)
at com.sun.xml.ws.transport.http.HttpAdapter.access$500(HttpAdapter.java:93)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:432)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:134)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:129)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:160)
at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) …Run Code Online (Sandbox Code Playgroud) 我正在使用CXF和Spring在JBoss 5.1 中发布和使用我的 WebServices 。一切正常。
但是,有一件事情我觉得很乏味:在applicationContext.xml 中为每个 WebService放置一个jaxws:endpoint标记。
真的没有办法用注释做到这一点吗?谢谢大家。
我使用以下 WSDL 托管 WCF Web 服务(使用 wsHttpBinding 和 SSL 实现传输安全的简单服务):
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="MagicEightBallService" targetNamespace="http://tempuri.org/">
<wsp:Policy wsu:Id="WSHttpBinding_TransportSecurity_IMagicEightBallService_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken RequireClientCertificate="false"/>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict/>
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
<wsaw:UsingAddressing/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://my.local.domain.name/MagicEightBall/MagicEightBallService.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
<xsd:import schemaLocation="http://my.local.domain.name/MagicEightBall/MagicEightBallService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="IMagicEightBallService_GetAdvice_InputMessage">
<wsdl:part name="parameters" element="tns:GetAdvice"/>
</wsdl:message>
<wsdl:message name="IMagicEightBallService_GetAdvice_OutputMessage">
<wsdl:part name="parameters" element="tns:GetAdviceResponse"/>
</wsdl:message> …Run Code Online (Sandbox Code Playgroud) 今天,有越来越多的 Web 服务被开发供内部使用以将应用程序连接在一起。我们没有 ESB 来控制和保护这个 Web 服务,所以我想什么是保护它们的好方法。
我们尝试设置双向 SSL,但我们无法控制特定 Web 服务的授权。
我的需要是能够控制哪个应用程序正在调用我的 Web 服务,以及该应用程序是否有权调用它。
我不喜欢 WS-Trust 和 Ws-Security,因为这会改变原始 SOAP 消息,但似乎它们不是其他解决方案。
任何的想法?
谢谢
我正在尝试调用在 wsdl 中配置了用户名令牌的 Web 服务:
<sp:SupportingTokens><wsp:Policy><sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<sp:HashPassword/>
<sp:WssUsernameToken10/>
</wsp:Policy>
</sp:UsernameToken>
</wsp:Policy>
</sp:SupportingTokens>
Run Code Online (Sandbox Code Playgroud)
soap 请求包含以下用于身份验证的信息:
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>user</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<env:Fault xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<faultcode>wsse:InvalidSecurity</faultcode>
<faultstring>Error on verifying message against security policy Error code:1000</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>
Run Code Online (Sandbox Code Playgroud)
有人能告诉我我做错了什么吗?
谢谢你。
我有一个wsdl嵌入式xsd.
<wsdl:definitions name="AcmeService"
targetNamespace="http://www.acme.com/services/Acme/WcfService"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://www.acme.com/services/Acme/WcfService"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema targetNamespace="http://www.acme.com/services/Acme/WcfService/Imports">
<xsd:import schemaLocation="http://services01.acme.com/WebServices/AcmeWcfClient/service/AcmeService.svc?xsd=xsd0" namespace="http://www.acme.com/services/Acme/WcfService" />
<xsd:import schemaLocation="http://services01.acme.com/WebServices/AcmeWcfClient/service/AcmeService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
</xsd:schema>
</wsdl:types>
<!-- Some more WSDL Content -->
</wsdl:definitions>
Run Code Online (Sandbox Code Playgroud)
我的“xsd”包含以下定义:
<xs:schema elementFormDefault="qualified" targetNamespace="http://www.acme.com/services/Acme/WcfService">
<xs:element name="SetApplication">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="application" nillable="true" type="tns:Application"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="Application">
<xs:sequence>
<xs:element minOccurs="0" name="SomeElement" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="AnotherElement" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="AcmeDetails" nillable="true" type="tns:Acme"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Application" nillable="true" type="tns:Application"/>
<xs:complexType name="Acme">
<xs:sequence>
<xs:element minOccurs="0" name="PropertyOne" nillable="true" type="xs:string"/>
<xs:element …Run Code Online (Sandbox Code Playgroud) 如何像这样修改响应的命名空间:
旧回复:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:GetAmountResponse xmlns:ns2="http://ws.dsi.otn.com/dab">
<etat>0</etat>
<montant>500.0</montant>
</ns2:GetAmountResponse>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
想要的新回复:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetAmountResponse xmlns="http://ws.dsi.otn.com/dab">
<etat>0</etat>
<montant>500.0</montant>
</GetAmountResponse>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
我想删除 ns2 namespce 前缀。
我创建了一个基于 wsdl 的 Web 服务,出于某种原因,我的一个元素没有 set 方法,只有 get 方法。
<xs:element name="Request">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns1:source_system"/>
<xs:element ref="ns1:target_system"/>
<xs:element ref="ns1:message_id"/>
<xs:element ref="ns1:message_send_timestamp"/>
<xs:element ref="ns1:request_type"/>
<xs:element ref="ns1:crm_customer_id"/>
<xs:element ref="ns1:crm_request_id"/>
<xs:element ref="ns1:donor_id"/>
<xs:element ref="ns1:identification_value"/>
<xs:element ref="ns1:identification_value_2" minOccurs="0"/>
<xs:element ref="ns1:identification_value_3" minOccurs="0"/>
<xs:element ref="ns1:dn_number_item" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Run Code Online (Sandbox Code Playgroud)
现在在我的程序中我只有 request.getDnNumberItem() 而我没有 request.setDnNumberItem()。对于我已经设置和获取的所有其他参数。
这以前发生在我身上,并以某种方式自行修复。
我很难让 Web 服务在 Websphere 上运行。我有一个 ejb-jar,它使用 JAXWS 注释 @WebService 定义了 Web 服务。然后将这个 ejb-jar 打包到一个耳朵中。我已经成功地将耳朵部署到 Glassfish 上并且能够访问我的 WebService。但是,当我尝试将同一个耳朵部署到 Websphere 8.5 中时,我没有看到任何暴露的 WebService。我需要采取哪些步骤才能使这个耳朵在 Websphere 中工作?
以及如何查看 Websphere 管理控制台中可用的 Web 服务?
谢谢
我有以下情况:
我们的应用程序中使用了逻辑表达式的树结构,并由四类层次结构定义:
Node是一个抽象的超类
OrNode是代表 OR 的 Node 的子类
AndNode是代表 AND 的 Node的子类
Leaf是代表持有一些数据的叶节点的 Node 的子类
现在应该将树结构转移到 Web 服务,该服务将对树进行一些操作(例如,通过收集一些其他信息来评估结果)
该 WS-Operation 的签名可能如下所示:
public TheResult evaluateTree(Node tree);
Run Code Online (Sandbox Code Playgroud)
我们正在使用 JAX-WS 并使用 wsimport 生成 Web 服务类。首先,没有为 OrNode、AndNode 和 Leaf 生成类。所以,我们手动添加了它们。我们将客户端使用的类转换为 wsimport 创建的生成类。接下来,我们要使用转换后的树作为参数调用 Web 服务操作。但是这里发生了一个异常,比如:
javax.xml.ws.soap.SOAPFaultException: javax.xml.bind.UnmarshalException - with linked exception: [javax.xml.bind.UnmarshalException: Unable to create an instance of InterfaceEntities.Node - with linked exception: [java.lang.InstantiationException]]
Run Code Online (Sandbox Code Playgroud)
以下是我们添加的 Wrapper 类和生成的类:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "OrNode")
public class OrNode
extends Node
{
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = …Run Code Online (Sandbox Code Playgroud)