我想使用以下代码调用我的Axis网络服务
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标题..请帮帮我..谢谢提前
答案 0 :(得分:0)
工作代码
//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);