解决方案 »

  1.   

    java的ws不能配置成普通键值对形式的get/post请求?配置成get/post就按照普通url那样请求就好了
      

  2.   

    jquery 不能webservice吧,改为JSON格式接口吧
      

  3.   


    本帖最后由 liyihongcug 于 2015-1-12 19:59 编辑
    问题 :
    jQuery consumes a  JAX-WS web service失败提示com.sun.xml.ws.transport.http.HttpAdapter$H)
    源代码
    myeclipse10 jax-ws webservicepackage server;public class Demo {public
    String sayHello(String name) {
    return name + ", hello!";
    }
    }package server;@javax.jws.WebService(targetNamespace = "http://server/", serviceName = "DemoService", portName = "DemoPort")
    public class DemoDelegate {        server.Demo demo = new server.Demo();        public String sayHello(String name) {
                    return demo.sayHello(name);
            }}
    测试都成功  http://localhost:8080/Demo/DemoPort
    Web Services
    Endpoint        Information
    Service Name:        {http://server/}DemoService
    Port Name:        {http://server/}DemoPort
    Address:        http://localhost:8080/Demo/DemoPort
    WSDL:        http://localhost:8080/Demo/DemoPort?wsdl
    Implementation class:        server.DemoDelegate客户端使用jquery 发生错误如上
    jsp代码如下<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <!DOCTYPE html>
    <html>
        <head>
            <title>通过ajax调用WebService服务</title>
            <script src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
    <script >
             function jquery(){    alert("Start JSON --- ");                                           $.post( "http://localhost:8080/Demo/DemoPort?wsdl/sayHello",  -------------------------//这里可能出问题 就是不知道格式
                '{"get":{"name":"5"}}', 
                  function(r) {
                alert("Book Title: " + r['return'].title);
                }, 
                "json" );               }
            </script>
        </head>
        <body>
                 <input type="button" value="jquery发送SOAP请求" id="btnJson">
                <input type="text" id="name">
                <div id="showInfo">
                </div>
        </body>
    </html>