gpt4 book ai didi

c# - 调用 SOAP 服务时参数作为 null 传递

转载 作者:行者123 更新时间:2023-12-01 04:12:44 25 4
gpt4 key购买 nike

对于那些 Web 和 SOAP 服务问题,我是个新手。我的问题如下:我有一个网络服务:

[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服务的 Debug模式下命中了断点。然而,参数 pMsg 作为 null 传递,尽管我可以看到它的内容,并且在调用 Web 服务之前在 eclipse 中调试期间它不为 null。

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>

我无法从这里到达任何地方,我使用了fiddler,但是由于我使用的是复杂的数据类型,所以我在fiddler上看不到它,实际上我无法将fiddler设置为端口30000上的本地主机(端口Web服务已发布) ),但我几乎不知道如何做到这一点。

如果有人提供意见或提供一点帮助,我们将不胜感激。

最佳答案

does the namespace in QName require the trailing slash? The missing parameter could be because of invalid namespace.

刚刚引用了评论,因此它可以被接受为答案:)

关于c# - 调用 SOAP 服务时参数作为 null 传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19765594/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com