我在同一机器上面部署了tomcat和websphere。
客户端放在了tomcat上,webservice部署在websphere上。
IE版本:9
FireFox版本:17.0.5
Chrome版本: 26.0.1410.64 m
通过IE测试,结果正常返回,进入jquery的success代码块中,弹出消息:
success la:
result1:hello Xiao Ming 但用Firefox和Chrome测试,程序进入了jquery的error代码块中,弹出错误信息:
error la
XMLHttpRequest.state:function{return e},
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(), //soap格式的消息
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>
jQueryAjaxjavawebserviceIE Firefox Chrome
客户端放在了tomcat上,webservice部署在websphere上。
IE版本:9
FireFox版本:17.0.5
Chrome版本: 26.0.1410.64 m
通过IE测试,结果正常返回,进入jquery的success代码块中,弹出消息:
success la:
result1:hello Xiao Ming 但用Firefox和Chrome测试,程序进入了jquery的error代码块中,弹出错误信息:
error la
XMLHttpRequest.state:function{return e},
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(), //soap格式的消息
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>
jQueryAjaxjavawebserviceIE Firefox Chrome
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货