Tag: web services

使用AXIS2将用户/密码添加到SOAPHeader以进行WebService客户端调用

请帮助:我试图从SOAPUI调用WebService,我注意到该服务需要用户名和密码,我通过请求参数提供。 我注意到原始XML包含添加到SOAPHeader的用户/密码片段。 摘录如下: testusertestpassword&RYadQak91mr7dB+5hyt8yw==2011-10-24T20:13:43.039Z 现在我想通过添加用户/密码详细信息来实现同样的目的,如下面的代码所示:代码片段是: org.tempuri.myService.MyServiceStub stub = new org.tempuri.myService.MyServiceStub(); ServiceClient sc = stub._getServiceClient(); HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator(); auth.setUsername(“testuser”); auth.setPassword(“password$”); sc.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,auth); org.tempuri.myService.MyServiceDocument myService4 = (org.tempuri.myService.MyServiceDocument)getTestObject(org.tempuri.myService.MyServiceDocument.class); MyService lval = MyService4.addNewMyService(); MyServiceParameters lvParams = lval.addNewParameters(); lvParams.setA(“24”); lvParams.setB(“10”); lval.setParameters(lvParams); myService4.setMyService(lval); 但我得到了Axis故障exception,需要帮助我在上面的代码中做错了。 轴故障exception详细信息: org.apache.axis2.AxisFault: Exception occurred while executing service ‘MyService’. at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531) at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) […]

为什么Java Client在运行时需要WSDL?

在为Java WS客户端生成工件之后, 为什么需要wsdllocation引用? 为什么运行时需要WSDL? 我可能会看到一些validation的原因,但不应该是可选的吗?

对JBoss web.xml的更改无效

我刚把它添加到我的JBOSS服务器上的web.xml中。 但它没有效果。 我仍然可以连接到不使用双向证书交换的端口。 有人有想法吗? Entire Application /* <!– attribute in the element of server.xml –> CONFIDENTIAL CLIENT-CERT 更新 实际上我似乎在原始post中犯了一个错误。 web.xml确实阻止用户使用http(下面的端口C)连接到webservice。 但是,仍然允许用户连接到不强制用户自己进行身份validation的端口(端口B)。 我认为用户应该能够连接到端口A(它有clientAuth=”true” ),但我不认为人们应该能够连接到端口B(它有clientAuth=”false” )。 摘自server.xml <Connector port="” … SSLEnabled=”true” … scheme=”https” secure=”true” clientAuth=”true” keystoreFile=”… .keystore” keystorePass=”pword” truststoreFile=”… .keystore” truststorePass=”pword” sslProtocol=”TLS”/> <Connector port="” … SSLEnabled=”true” … scheme=”https” secure=”true” clientAuth=”false” keystoreFile=”… .keystore” keystorePass=”pword” sslProtocol = “TLS” /> […]

sun-jaxws.xml中的JAX-WS多端点

刚开始使用JAX-WS。 我在一个WAR文件中创建了2个测试Web服务,如下所示…. package com.djs; import javax.jws.WebService; @WebService() public class AddTwoInts { public int performAdd(int firstNum, int secondNum) { return firstNum + secondNum; } } 和….. package com.djs; import javax.jws.WebService; @WebService() public class SayHello { public String sayHello(String inwards) { return “Hello ” + inwards; } } 这是我的web.xml com.sun.xml.ws.transport.http.servlet.WSServletContextListener jaxws com.sun.xml.ws.transport.http.servlet.WSServlet jaxws / 这是sun-jaxws.xml 我部署到Tomcat 7并使用http://localhost:8080/MyApp/AddTwoInts?wsdl来获取AddTwoInts的WSDL […]

Spring MVC @ResponseBody返回一个List

我们想创建一个“WebService”,它返回特定对象的列表。 我们想通过apache http客户端库从另一个java程序中调用这个web服务。 此时,如果我们从Firefox调用Web服务,则会出现406错误页面。 我们是否必须使用JSON或XML来传输列表? 怎么做,以及如何使用apache http客户端获取列表? 谢谢。 [编辑] 唯一有效的方法是使用JAXB注释创建一些实体,以便序列化为XML。 @XmlRootElement(name = “person”) public class Person { private String id; public String getId() { return id; } public void setId(String id) { this.id = id; } } @XmlRootElement(name = “persons”) public class PersonList { @XmlElement(required = true) public List persons; public List getData() { return […]

如何从Web服务返回XML

这可能是疯狂/愚蠢/愚蠢/冗长的问题之一,因为我是网络服务的新手。 我想写一个Web服务,它将以XML格式返回答案(我正在使用我的服务进行YUI自动完成)。 我正在使用Eclipse和Axis2并关注http://www.softwareagility.gr/index.php?q=node/21我希望以下列格式回复 code元素的数量可能因响应而异。 直到现在我尝试了以下方法 1)使用String缓冲区创建XML并返回字符串。 (我提供部分代码以避免混淆) public String myService () { // Some other stuff StringBuffer outputXML = new StringBuffer(); outputXML.append(“”); outputXML.append(“”); while(SOME_CONDITION) { // Some business logic outputXML.append(“”+””); } outputXML.append(“”); return (outputXML.toString()); } 它使用不需要的和元素提供以下响应。 但它没有使用YUI自动完成(可能是因为它需要上面提到的格式的响应) 2)使用DocumentBuilderFactory : 喜欢 public Element myService () { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = factory.newDocumentBuilder(); Document doc […]

使用paypal api时无法建立SOAP连接

我正在尝试使用paypal soap客户端,并使用Paypal Express Checkout和Java参考执行setExpressCheckout方法。 所以这里我只使用paypal-base.jar和paypal-stubs.jar而不是soap客户端(从wsdl生成)。 public class SetExpressCheckoutService{ private static Logger log = Logger.getLogger(SetExpressCheckoutService.class); public static void main(String[] args){ SetExpressCheckoutService setExpressCheckoutService = new SetExpressCheckoutService(); //the parameters for the service Long userId = 5l; String amount = “25”; String returnURL = “http://localhost:8080/integratingstuff-paypal/return_after_payment.xhtml”; String cancelURL = “http://localhost:8080/integratingstuff-paypal/cancel_payment.xhtml”; PaymentActionCodeType paymentAction = PaymentActionCodeType.Sale; CurrencyCodeType currencyCode = CurrencyCodeType.EUR; try { […]

访问用java编写的Web服务方法时的java.lang.ClassCastException。 JAXB

我正在编写一个应用程序,我必须与MS SQL数据库进行交互。 在我的应用程序中,我正在创建Web服务(使用javax.jws)来访问数据库表。 我在Web服务中创建一个操作(方法),返回类型为java.lang.Object [] [],如下所示: @WebMethod(operationName =“get_HistoryInfoByUser”) public java.lang.Object[][] get_HistoryInfoByUser(@WebParam(name = “email_Id”) String email_Id) throws Exception{ java.lang.Object[][] historyInfo = null; // some code here return historyInfo; } 并且为了在我的应用程序中调用Web服务操作(方法),我正在编写以下代码: public Object[][] get_HistoryInfoByUser(String email_Id) { java.util.List historyInfo = null; try { historyInfo = port.getHistoryInfoByUser(email_Id); } catch (Exception_Exception ex) { ex.printStackTrace(); } return (Object[][]) historyInfo.toArray(); } 但我得到一个例外 […]

使用泽西客户端连接池

我是泽西岛的新手,我做了一次搜索,但无法弄清楚是否有一种方法可以让泽西客户端使用连接池而不是每次我们发送新请求时都创建连接。 整个想法是重用池中的连接集,这将节省批量或资源。 仅供参考我不是在寻找连接:保持活力 。 这就是我现在正在做的事情 public void postData() { Client client = new Client(); WebResource webResource = client.resource(“http://SomeService.com/..”); ClientResponse response = webResource.accept(“text/plain”).get(ClientResponse.class); System.out.println(response.getStatus()); System.out.println(response.getEntity(String.class)); } 任何帮助都非常值得注意,期待代码片段。 提前致谢。

使用JAX-WS更改运行时生成的WSDL中的schemaLocation和soap:address位置

是否可以在JAX-WS WSDL中配置位置( schemaLocation和soap:address location )? 当我部署下面的示例时,’servername’将是localhost,’serverport’将是Web应用程序的本地端口号。 但是,我想将这些重新配置为代理服务器名称和重定向到服务的服务器端口。 这是可能的,我将如何实现它? 部署环境是Tomcat和Apache。 我有以下服务类: @WebService public class AuthenticationService { …. public AuthenticationService(){} @WebMethod public AuthenticationResult checkAuthentication( @WebParam(name = “authentication”) Authentication authentication, @WebParam(name = “privilege”) Privilege privilege) { …. } } 运行时,WSDL看起来像这样: 任何帮助将不胜感激。