java调用asmx报异常
下列是 SOAP 1.1 要求與回應的範例。預留位置顯示之處必須代入實際的值。
POST /MyGameMemberApp/MemberGetData.asmx HTTP/1.1
Host: b2b.mygame.com.tw
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetMyCardMemberAuth"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetMyCardMemberAuth xmlns="http://tempuri.org/">
<FactoryId>string</FactoryId>
<GameId>string</GameId>
<FactoryServiceId>string</FactoryServiceId>
<FactoryReturnUrl>string</FactoryReturnUrl>
</GetMyCardMemberAuth>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetMyCardMemberAuthResponse xmlns="http://tempuri.org/">
<GetMyCardMemberAuthResult>
<ReturnMsgNo>int</ReturnMsgNo>
<ReturnAuthCode>string</ReturnAuthCode>
<ReturnTradeSeq>string</ReturnTradeSeq>
</GetMyCardMemberAuthResult>
</GetMyCardMemberAuthResponse>
</soap:Body>
</soap:Envelope>
以下是我的测试代码
package hk.egame.port2.util;
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class HttpTest {
/**
* @param args
*/
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
String service_url="http://************/MyGameMemberApp/MemberGetData.asmx";
String method="GetMyCardMemberAuth";
String factoryReturnUrl="www.baidu.com";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(service_url));
// 设置要调用的方法
//We have to figure our the namespace. The java doesn't know where is the namespace
call.setOperationName(new QName("http://tempuri.org/",method));
// 该方法需要的参数
call.addParameter(new QName("http://tempuri.org/","FactoryId"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org/","GameId"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org/","FactoryServiceId"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org/","FactoryReturnUrl"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
// 方法的返回值类型
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://tempuri.org/GetMyCardMemberAuth");
//call.setSOAPActionURI(service_url);
// 调用该方法, new Object[] { CustNo, passwd, Jobno}为参数列表
String xmlStr = call.invoke(new Object[] { "xiaonei", "smzt", "MFSD000310","www.baidu.com"}).toString();
System.out.println(xmlStr);
}
}
以下是返回的异常
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2467)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at hk.egame.port2.util.HttpTest.main(HttpTest.java:56)
{http://xml.apache.org/axis/}hostname:S
请问谁做过这方面的调用,求帮忙
POST /MyGameMemberApp/MemberGetData.asmx HTTP/1.1
Host: b2b.mygame.com.tw
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetMyCardMemberAuth"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetMyCardMemberAuth xmlns="http://tempuri.org/">
<FactoryId>string</FactoryId>
<GameId>string</GameId>
<FactoryServiceId>string</FactoryServiceId>
<FactoryReturnUrl>string</FactoryReturnUrl>
</GetMyCardMemberAuth>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetMyCardMemberAuthResponse xmlns="http://tempuri.org/">
<GetMyCardMemberAuthResult>
<ReturnMsgNo>int</ReturnMsgNo>
<ReturnAuthCode>string</ReturnAuthCode>
<ReturnTradeSeq>string</ReturnTradeSeq>
</GetMyCardMemberAuthResult>
</GetMyCardMemberAuthResponse>
</soap:Body>
</soap:Envelope>
以下是我的测试代码
package hk.egame.port2.util;
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class HttpTest {
/**
* @param args
*/
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
String service_url="http://************/MyGameMemberApp/MemberGetData.asmx";
String method="GetMyCardMemberAuth";
String factoryReturnUrl="www.baidu.com";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(service_url));
// 设置要调用的方法
//We have to figure our the namespace. The java doesn't know where is the namespace
call.setOperationName(new QName("http://tempuri.org/",method));
// 该方法需要的参数
call.addParameter(new QName("http://tempuri.org/","FactoryId"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org/","GameId"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org/","FactoryServiceId"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org/","FactoryReturnUrl"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
// 方法的返回值类型
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://tempuri.org/GetMyCardMemberAuth");
//call.setSOAPActionURI(service_url);
// 调用该方法, new Object[] { CustNo, passwd, Jobno}为参数列表
String xmlStr = call.invoke(new Object[] { "xiaonei", "smzt", "MFSD000310","www.baidu.com"}).toString();
System.out.println(xmlStr);
}
}
以下是返回的异常
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2467)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at hk.egame.port2.util.HttpTest.main(HttpTest.java:56)
{http://xml.apache.org/axis/}hostname:S
请问谁做过这方面的调用,求帮忙
...全文
相关推荐
Java调用asmx(WebService)
其中,ASMX是基于SOAP协议的一种WebService实现方式。本文将详细介绍如何使用Java语言调用ASMX类型的WebService,并提供一个具体的示例来帮助理解整个过程。
java调用.net发布的webservice(asmx)
错误处理和异常捕获:在调用Web服务时,应捕获可能抛出的异常,如SOAPFaultException、IOException等,并进行适当的错误处理。
java调用.asmx详细实例
JAVA调用.asmx详细实例,应用于java web 工程中。很细致哟
Java调用ASP.NET的WebService接口实例
本文介绍如何在Java中利用Axis2框架调用ASP.NET发布的WebService接口。通过构建SOAP请求,使用OMElement封装消息体,并借助ServiceClient实现与ASMX服务的
Java调用WebService接口的方法
**处理结果和异常**:调用`invoke()`方法可能会抛出异常,所以我们需要捕获这些异常并进行适当的错误处理。在正常情况下,结果会被打印出来,如示例所示:"Result: 3"。


