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
请问谁做过这方面的调用,求帮忙