0 0

通过jquery调用Axis2 WebService,在IE上返回正确结果,但在Firefox和Chrome上却返回错误,附简单代码,求解!10

我在同一机器上面部署了tomcat和websphere。
客户端放在了tomcat上,webservice部署在websphere上。
通过IE测试,结果正常返回,进入jquery的success代码块中,弹出消息:
success la:
result1:hello Xiao Ming

但用Firefox和Chrome测试,程序进入了jquery的error代码块中,弹出错误信息:
error la
XMLHttpRequest.state:function{return 3},
XMLHttpRequest.readyState:0,
textStatus:error,
XMLHttpRequest.responseText:

客户端代码html 调用webservice的代码片段如下:

$('#callwebserviceId').click(function() {
	  
		$.ajax({  
		url: 'http://localhost:9081/xxx/RetriveHelloWordService?wsdl/sayHello',
        type: 'post',
		dataType: 'xml',
		data: populateXML(),
        contentType: 'text/xml;charset="utf-8"', 
		
                success:function(zz){         
                    alert("success la:");
					alert("result1:"+$(zz).text());
                },
				error: function(XMLHttpRequest, textStatus) {
						alert("error la");
                        alert("XMLHttpRequest.state:"+XMLHttpRequest.state+"-XMLHttpRequest.readyState:"+XMLHttpRequest.readyState+"-textStatus:"+textStatus+"-XMLHttpRequest.responseText:"+XMLHttpRequest.responseText);
                }
			});
    });


function populateXML(){
		var xmlData="<soapenv:Envelope xmlns:q0=\"http://action.test.com/\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><tns:sayHello xmlns:tns=\"http://action.test.com/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://action.test.com/ RetriveHelloWordService_schema1.xsd \"><arg0> Xiao Ming</arg0></tns:sayHello></soapenv:Body></soapenv:Envelope>";
		
		alert(xmlData);
		return xmlData;
		
	}



服务器端的webservice 服务类
package com.test.action;

public class RetriveHelloWord {
	public String sayHello(String name){
		System.out.println("got message:"+name);
		return "hello"+name;
	}
}




响应了wsdl文件:
<?xml version="1.0" encoding="UTF-8"?><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI IBM 2.2.1-11/30/2010 12:42 PM(foreman)-. --><definitions name="RetriveHelloWordService" targetNamespace="http://action.test.com/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://action.test.com/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <types>
    <xsd:schema>
      <xsd:import namespace="http://action.test.com/" schemaLocation="RetriveHelloWordService_schema1.xsd"/>
    </xsd:schema>
  </types>
  <message name="sayHello">
    <part element="tns:sayHello" name="parameters"/>
  </message>
  <message name="sayHelloResponse">
    <part element="tns:sayHelloResponse" name="parameters"/>
  </message>
  <portType name="RetriveHelloWordDelegate">
    <operation name="sayHello">
      <input message="tns:sayHello" wsam:Action="http://action.test.com/RetriveHelloWordDelegate/sayHelloRequest"/>
      <output message="tns:sayHelloResponse" wsam:Action="http://action.test.com/RetriveHelloWordDelegate/sayHelloResponse"/>
    </operation>
  </portType>
  <binding name="RetriveHelloWordPortBinding" type="tns:RetriveHelloWordDelegate">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="sayHello">
      <soap:operation soapAction=""/>
      <input>
        <soap:body use="literal"/>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
    </operation>
  </binding>
  <service name="RetriveHelloWordService">
    <port binding="tns:RetriveHelloWordPortBinding" name="RetriveHelloWordPort">
      <soap:address location="http://localhost:9081/xxx/RetriveHelloWordService"/>
    </port>
  </service>
</definitions>


感觉这是webservice ajax 或者是 jquery对浏览器不兼容造成的,有谁知道?谢谢!
问题补充
没人知道吗?

问题补充:IE版本:9
FireFox版本:17.0.5
Chrome版本: 26.0.1410.64 m

1个答案 按时间排序 按投票排序

0 0

我也遇到同样的问题,希望楼主解决后,能发布一下答案,谢啦。

2013年8月02日 11:33

相关推荐

Global site tag (gtag.js) - Google Analytics