Tag: soap

将SOAP响应转换为JSONArray

我有SOAP响应如下。 我想迭代soap消息,并希望以JSONArray格式获取listMetadataResponse标记中的数据。 这是我的SOAP响应示例: 00528000001m5RRAAY Hariprasath Thanarajah 1970-01-01T00:00:00.000Z objects/EmailMessage.object EmailMessage 00528000001m5RRAAY Hariprasath Thanarajah 1970-01-01T00:00:00.000Z CustomObject 00528000001m5RRAAY Hariprasath Thanarajah 1970-01-01T00:00:00.000Z objects/EmailMessage.object EmailMessage 00528000001m5RRAAY Hariprasath Thanarajah 1970-01-01T00:00:00.000Z CustomObject 我希望将每个结果节点作为JSONObject与每个属性节点和值作为JSON中的键值对进行。在这种情况下,我希望结果为JSONArray,其中包含两个结果JSONObject。 我试过这段代码。 我正在获取节点名称,但我没有得到节点值。 private static Document loadXMLString(String response) throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(new StringReader(response)); return db.parse(is); } public static […]

解析的SOAP响应与接收的响应不同

我试图解析SOAP响应。 我可以使用以下行显示完整的响应。 System.out.println(“Response: ” + out.toString()); 但是,当我解析响应并对解析后的响应进行编组时,它会显示错误的响应。 package-info.java @XmlSchema( namespace = “http://v3.hotel.wsapi.ean.com/”, elementFormDefault = XmlNsForm.QUALIFIED) package com.ean; import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlSchema; 我的代码 @XmlRootElement(name=”getListResponse”) @XmlAccessorType(XmlAccessType.FIELD) public class GetListResponse { @XmlElement(name=”HotelListResponse”) private HotelListResponse hotelListResponse; public GetListResponse() { this.hotelListResponse = new HotelListResponse(); } …getter and setter } @XmlRootElement(name =”HotelListResponse”) @XmlAccessorType(XmlAccessType.FIELD) public class HotelListResponse { @XmlElement(name = “customerSessionId”) String […]

CXF抛出任何政策选择都不能满足

我正在尝试使用CXF为.NET Web服务编写Java客户端,但在调用“client.getConduit()”时,它会抛出exception – org.apache.cxf.ws.policy.PolicyException:不能满足任何策略备选方案。 请帮忙! 这是代码片段 – ServiceClass service = new ServiceClass(); PortClass port = service.getPort(ServiceClass.class); Client client = ClientProxy.getClient(port); HTTPConduit httpConduit = (HTTPConduit) client.getConduit(); final HTTPClientPolicy httpClientPolicy = httpConduit.getClient(); httpClientPolicy.setAllowChunking(false); httpClientPolicy.setAutoRedirect(true); final BindingProvider bindingProvider = (BindingProvider) port; final Map requestContext = bindingProvider.getRequestContext(); final Credentials credentials = new NTCredentials(USERNAME, PASSWORD, “”, DOMAIN); requestContext.put(Credentials.class.getName(), credentials); requestContext.put(AsyncHTTPConduit.USE_ASYNC, […]

使用JAX-WS(服务器端)的SOAP标头

要求是在每个WebService请求中的Soap Message标头中包含安全属性。 一种方法是: @WebService @SOAPBinding ( style = javax.jws.soap.SOAPBinding.Style.DOCUMENT, use = javax.jws.soap.SOAPBinding.Use.LITERAL ) public interface UserService { @WebMethod public AuthenticateResponse authenticateUser(AuthenticateRequest request, @webParam(header=true) ApplicationCredential appcredential); @WebMethod public UserDetailResponse getUserDetail(UserDetailRequest request, @webParam(header=true) ApplicationCredential appcredential); } 但是,通过上述方法,我需要在每个操作中包含ApplicationCredential。 它看起来不太好。 我正在寻找是否可以在BaseRequest Class中包含这个ApplicationCredential类,并提到它将成为Soap Header的一部分(通过一些注释),这将非常有用。 例如: public class BaseRequest { @SomeAnnotation which states that Appcedential is a part of Soap Header […]

为什么服务提供商返回SOAP Webservice错误?

我正在使用由webservicex服务器开发的SOAP web-service (从这里下载)来开发一个以IP地址作为输入的国家定位器应用程序。 使用wsimport导入jar文件和java文件。 现在,开发了一个java应用程序,它通过将输入作为IP地址返回国家名称。 一切都按计划工作,没有任何语法错误。 但是在执行java程序时,它返回了一个我无法追溯的错误(我是学习者)。 我不确定它是WS或Jar文件的问题。 错误如下: Exception in thread “main” com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: System.Web.Services.Protocols.SoapException: Server was unable to process request. —> System.NullReferenceException: Object reference not set to an instance of an object. at WebserviceX.Service.Adapter.IPAdapter.CheckIP(String IP) at WebserviceX.Service.GeoIPService.GetGeoIP(String IPAddress) — End of inner exception stack trace — Please see […]

Axis2 ServiceClient选项忽略超时

我在版本中使用Axis2: Implementation-Version: 1.7.0-SNAPSHOT Implementation-Vendor-Id: org.apache.axis2 Implementation-Vendor: The Apache Software Foundation Jenkins-Build-Number: 1847 我想将ServiceClient的超时设置为2000毫秒,这是我们的代码: Options options = new Options(); options.setTo(new EndpointReference(getUserServiceEndPoint())); options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE); // setting timeout to 2 second should be sufficient, if the server is // not available within the 3 second interval you got a problem anyway options.setTimeOutInMilliSeconds(2000); ServiceClient sender = new ServiceClient(); sender.engageModule(new […]

Axis2和Webservices:文件上传

我正在尝试使用Axis2编写一个简单的Web服务。 它的行为非常简单:它在输入中获取一个文件并存储它。 我已经尝试了几件事来做这个“简单”的文件上传服务。 最初,我还尝试使用Java2WSDL和WSDL2Java来创建WSDL文件,并希望传递java.io.File数据类型的客户端。 当然它没有用。 我现在正尝试使用SOAP附件和MTOM或SwA上传文件。 我在axis2 \ WEB-INF \ conf \ axis2.xml中启用了它们 服务器端,我的服务操作的签名是: public String uploadAttachment(OMElement omEle); 这是使用Java2WSDL工具生成的WSDL: 客户端,我试图打电话给服务: Options options = new Options(); options.setTo(new EndpointReference(“http://localhost:8080/axis2/services/ImportModule”)); options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE); options.setTransportInProtocol(Constants.TRANSPORT_HTTP); options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI); ServiceClient sender = new ServiceClient(null,null); sender.setOptions(options); OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP); MessageContext mc = new MessageContext(); SOAPFactory factory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope env = factory.getDefaultEnvelope(); mc.setEnvelope(env); […]

具有长请求的Apache CXF客户端“连接重置”

我有一个SOAP Web服务。 从SoapUI调用它时,无论消息内容的大小如何,请求都能正常工作。 如果我从Apache CXF客户端代码发出相同的请求,它可以处理小请求,但如果我的消息内容太长,我会得到“连接重置”,但有以下exception: Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(Unknown Source) at com.sun.net.ssl.internal.ssl.InputRecord.readFully(Unknown Source) at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(Unknown Source) at com.sun.net.ssl.internal.ssl.AppInputStream.read(Unknown Source) at java.io.BufferedInputStream.fill(Unknown Source) at java.io.BufferedInputStream.read1(Unknown Source) at java.io.BufferedInputStream.read(Unknown Source) at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source) at sun.net.www.http.HttpClient.parseHTTP(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at java.net.HttpURLConnection.getResponseCode(Unknown Source) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1606) at […]

如何确定Java Web服务是JAX-WS还是JAX-RPC

我被要求完成一些与应用程序中的许多Web服务相关的文档,并指出每个服务是否使用JAX-WS或JAX-RPC实现。 这些服务已经开发了很多年,可能使用各种方法,包括RAD内置的Web服务向导,以及使用从Maven调用的wsimport。 而且他们也随着时间的推移而改变和发展 – 即使在有些原始文件说这项服务是其中之一的情况下,我也不确定他们可以信任多少。 如果服务是JAX-WS或JAX-RPC,有没有明确的标记让我知道? 我可以完全访问源代码,WSDL和模式。 我只是不确定要找什么。

获取SoapBody元素值

这是我从服务器获得的响应,虽然我可以获取MM7Version元素值,但我无法获取Status元素值。 它返回null。 SoapMeesage XML响应: TID.BIP_TRASNID.20041103.135200.001 5.6.0 2602Invalid status Java代码: SOAPMessage response = connection.call(message, endpoint); SOAPEnvelope env= response.getSOAPPart().getEnvelope(); SOAPBody sb = env.getBody(); Name ElName = env.createName(“Status”); //Get child elements with the name XElement Iterator it = sb.getChildElements(ElName); //Get the first matched child element. //We know there is only one. SOAPBodyElement sbe = (SOAPBodyElement) it.next(); //Get the […]