繁体   English   中英

从jQuery调用Axis Web服务

[英]Calling Axis webservice from jquery

我想使用以下代码调用我的Axis Web服务

var wsUrl = "http://localhost:8080/TestServ/services/TestCls?wsdl";

var soapreq = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:cod=\"http://codon.com\">+"<soapenv:Header/>"+"<soapenv:Body>"+"<cod:testMethod>"+"<cod:name>hai</cod:name>"+"</cod:testMethod>"+"</soapenv:Body>"+"</soapenv:Envelope>";

var soapaction = "http://codon.com/testMethod";
jQuery.support.cors = true; 
        $.ajax({
                type: "POST",
                url: wsUrl,
                contentType:  'text/xml; charset=utf-8' ,
                dataType: "xml",
                data: soapreq ,
                SOAPAction: soapaction,
        //async: false,
        //processData: false,
        crossDomain: true,
        success: processSuccess,
                error: processError
            });

但是在我的服务端出现以下错误...

May 10, 2013 12:18:52 PM org.apache.axis.transport.http.AxisServlet getSoapAction
SEVERE: Generating fault class
AxisFault
  faultCode: {http://xml.apache.org/axis/}Client.NoSOAPAction
  faultSubcode: 
  faultString: no SOAPAction header!
  faultActor: 
 faultNode: 
 faultDetail: 
 {http://xml.apache.org/axis/}stackTrace:no SOAPAction header!
at org.apache.axis.transport.http.AxisServlet.getSoapAction(AxisServlet.java:1013)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:678)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at       org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at 

但是我也在发送SOAPAction标头..请帮助我..谢谢

工作代码

    //webservice calling
var xmlhttp = new XMLHttpRequest();
var wsUrl = "http://localhost:8080/WebSer/services/EmailClient?wsdl";
xmlhttp.open('POST', wsUrl, false);
var soapaction = "http://codon.com/login"; // available in wsdl file

var soapRequest = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:cod=\"http://codon.com\">"+"<soapenv:Header xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"+"<soapenv:Body>"+"<cod:login>"+"<acc_name>"+account+"</acc_name>"+"<uname>"+username+"</uname>"+"<pass>"+pwd+"</pass>"+"</cod:login>"+"</soapenv:Body>"+"</soapenv:Envelope>"; // get this from soap UI Tool

xmlhttp.onreadystatechange = function () {

    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {


}
// Send the POST request
            xmlhttp.setRequestHeader('Content-Type', 'text/xml');
            xmlhttp.setRequestHeader('SOAPAction', soapaction);
            xmlhttp.send(soapRequest);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM