1
我对这些Web和SOAP服务问题有点新手。我的问题是: 我有一个Web服务:当调用一个SOAP服务参数传递为null
[WebService(Namespace = "http://localhost:30000/QlogisticIntegration.asmx")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class QlogisticIntegration : System.Web.Services.WebService {
[WebMethod(Description = "Qlogistik.")]
public QlogisticResultEntity DoAccountingForProducts(QlogisticInputEntity pMsg)
{
MessagingProcessor mProcessor = new MessagingProcessor();
ResponseMessage respMsg = null;
QlogisticResultEntity resultMessage = new QlogisticResultEntity();
DateTime vToday = Global.GetChannel("QLOGISTIC").Today;
Intertech.Core.Framework.Context.CurrentContext.Branch = Global.GetBranch(9019);
Decimal exchangeRate = FxRatesQuery.GetRates(9019, "T", "D", "A",
pMsg.CurrencyCode,
vToday);
CqlogMessage msg = new CqlogMessage();
msg.QlogInputEntity = pMsg;
.
.
.
.
return resultMessage;
}
}
这里是我如何通过java调用它:
public tr.com.intertech.core.QlogisticResultEntity DoAccountingForProducts(tr.com.intertech.core.QlogisticInputEntity pMsg) throws java.rmi.RemoteException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
}
org.apache.axis.client.Call _call = createCall();
_call.addParameter(new javax.xml.namespace.QName("http://localhost:30000/QlogisticIntegration.asmx/", "pMsg"), new javax.xml.namespace.QName("http://localhost:30000/QlogisticIntegration.asmx/", "QlogisticInputEntity"), tr.com.intertech.core.QlogisticInputEntity.class, javax.xml.rpc.ParameterMode.IN);
_call.setUseSOAPAction(true);
_call.setReturnType(new javax.xml.namespace.QName("http://localhost:30000/QlogisticIntegration.asmx/", "QlogisticResultEntity"), tr.com.intertech.core.QlogisticResultEntity.class);
_call.setSOAPActionURI("http://localhost:30000/QlogisticIntegration.asmx/DoAccountingForProducts");
_call.setEncodingStyle(null);
_call.setScopedProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
_call.setScopedProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
_call.setOperationStyle("wrapped");
_call.setOperationName(new javax.xml.namespace.QName("http://localhost:30000/QlogisticIntegration.asmx/", "DoAccountingForProducts"));
_call.setReturnQName(new javax.xml.namespace.QName("http://localhost:30000/QlogisticIntegration.asmx/", "DoAccountingForProductsResult"));
java.lang.Object _resp = _call.invoke(new java.lang.Object[] {pMsg});
if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException)_resp;
}
else {
try {
return (tr.com.intertech.core.QlogisticResultEntity) _resp;
} catch (java.lang.Exception _exception) {
return (tr.com.intertech.core.QlogisticResultEntity) org.apache.axis.utils.JavaUtils.convert(_resp, tr.com.intertech.core.QlogisticResultEntity.class);
}
}
}
我同时调试Web服务和Java应用程序(实际上是网站),并且当我向Web服务发出请求时,它会以Web服务的调试模式命中断点。然而,参数pMsg是作为null传递的althoguh我可以看到它的内容,并且在eclipse中的调试期间它不是null,在调用Web服务之前。
pMsg对象的所有属性都被初始化并给出了一个值,正如您看到的参数名称和类型相同。
下面是相关的WSDL:
<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://localhost:30000/QlogisticIntegration.asmx" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://localhost:30000/QlogisticIntegration.asmx" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified" targetNamespace="http://localhost:30000/QlogisticIntegration.asmx">
- <s:element name="DoAccountingForProducts">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="pMsg" type="tns:QlogisticInputEntity" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
</wsdl:definitions>
我无法从这里的任何地方,我用小提琴手,但因为我使用的是复杂的数据类型,我看不出它的小提琴手,其实我做不到在端口30000(端口Web服务已发布)上将fiddler设置为localhost,并且我几乎不知道如何执行此操作。
如果有人给予意见或一点帮助,将非常感激。
我真的不知道如何从Java调用SOAP,但只是为了验证 - 并在QName的命名空间需要尾随斜线?缺少的参数可能是由于命名空间无效。上面的java代码的 – jtmnt
做的东西,我也没有关于它的深层信息。 我试图删除URI中的最后一个斜杠。现在错误消息是:System.Web.Services.Protocols.SoapException:服务器无法读取请求。 ---> System.InvalidOperationException:XML文档中存在错误(5,5)。 –
重建客户端和服务项目后,它开始工作。谢谢。 –