简体   繁体   English

调用Web服务并为响应对象获取null

[英]Calling web service and getting null for response object

I am working with a 3rd party web service which is written in Java/Axis. 我正在使用用Java / Axis编写的第三方Web服务。 I have not worked much with WCF so I am trying to feel my way through this. 我与WCF的合作并不多,所以我试图通过这种方式感到自己的方式。 I was able to generate the class from the wsdl and using Fiddler I am able to see the call being made to the service, and a response being returned. 我能够从wsdl生成类,并使用Fiddler能够看到对服务的调用,并返回了响应。 But in my code, my response is empty and I am not sure why I am not seeing the response. 但是在我的代码中,我的答复是空的,并且我不确定为什么看不到该答复。 I did read one post about the namespace, and tried to update it, but no luck. 我确实读过一篇有关名称空间的文章,并尝试对其进行更新,但是没有运气。 Below is the generated class, the wsdl and the response from the web service. 下面是生成的类,wsdl和来自Web服务的响应。 Is there an issue with the auto generated class? 自动生成的类有问题吗? Why is my response not being consumed by the C# code? 为什么我的响应没有被C#代码占用?

This is the generated class. 这是生成的类。 I only included the methods I am calling since this file is over 5000 lines and most of it will not be used by us. 我只包含了我要调用的方法,因为此文件超过5000行,并且大多数将不被我们使用。

[GeneratedCodeAttribute("wsdl", "4.0.30319.18020")]
[DebuggerStepThroughAttribute()]
[DesignerCategoryAttribute("code")]
[WebServiceBindingAttribute(Name = "grandeFacadeSoapBinding", Namespace = "http://localhost:8081/axis/services/grandeFacade")]
public partial class grandeFacadeService : SoapHttpClientProtocol
{
    private SendOrPostCallback EnterpriseObjectsOperationCompleted;

    private SendOrPostCallback EnterpriseObjecOperationCompleted;

    public grandeFacadeService()
    {
        this.Url = "http://example.com:8081/axis/services/grandeFacade";
    }       

    public event EnterpriseObjectsCompletedEventHandler EnterpriseObjectsCompleted;

    public event EnterpriseObjecCompletedEventHandler EnterpriseObjecCompleted;

    [SoapDocumentMethodAttribute("", RequestNamespace = "http://localhost:8180/grandeFacade/services/grandeFacade", ResponseNamespace = "http://localhost:8180/grandeFacade/services/grandeFacade", Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
    [return: XmlElementAttribute("EnterpriseObjectsReturn")]
    public WebServiceResp EnterpriseObjects([Serialization.XmlElementAttribute("EnterpriseObjValues")] EnterpriseObjValues[] EnterpriseObjValues)
    {
        object[] results = this.Invoke("EnterpriseObjects", new object[] { EnterpriseObjValues });
        return ((WebServiceResp)(results[0]));
    }

    public IAsyncResult BeginEnterpriseObjects(EnterpriseObjValues[] EnterpriseObjValues, AsyncCallback callback, object asyncState)
    {
        return this.BeginInvoke("EnterpriseObjects", new object[] { EnterpriseObjValues}, callback, asyncState);
    }

    public WebServiceResp EndEnterpriseObjects(IAsyncResult asyncResult)
    {
        object[] results = this.EndInvoke(asyncResult);
        return ((WebServiceResp)(results[0]));
    }

    public void EnterpriseObjectsAsync(EnterpriseObjValues[] EnterpriseObjValues)
    {
        this.EnterpriseObjectsAsync(EnterpriseObjValues, null);
    }

    public void EnterpriseObjectsAsync(EnterpriseObjValues[] EnterpriseObjValues, object userState)
    {
        if ((this.EnterpriseObjectsOperationCompleted == null))
        {
            this.EnterpriseObjectsOperationCompleted = new SendOrPostCallback(this.OnEnterpriseObjectsOperationCompleted);
        }
        this.InvokeAsync("EnterpriseObjects", new object[] { EnterpriseObjValues}, this.EnterpriseObjectsOperationCompleted, userState);
    }

    private void OnEnterpriseObjectsOperationCompleted(object arg)
    {
        if ((this.EnterpriseObjectsCompleted != null))
        {
            InvokeCompletedEventArgs invokeArgs = ((InvokeCompletedEventArgs)(arg));
            this.EnterpriseObjectsCompleted(this, new EnterpriseObjectsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

    [SoapDocumentMethodAttribute("", RequestNamespace = "http://localhost:8180/grandeFacade/services/grandeFacade", ResponseNamespace = "http://localhost:8180/grandeFacade/services/grandeFacade", Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
    [return: XmlElementAttribute("EnterpriseObjecReturn")]
    public wsResponse EnterpriseObjec(EnterpriseObjValues EnterpriseObjValues)
    {
        object[] results = this.Invoke("EnterpriseObjec", new object[] { EnterpriseObjValues });
        return ((wsResponse)(results[0]));
    }

    public IAsyncResult BeginEnterpriseObjec(EnterpriseObjValues EnterpriseObjValues, AsyncCallback callback, object asyncState)
    {
        return this.BeginInvoke("EnterpriseObjec", new object[] { EnterpriseObjValues}, callback, asyncState);
    }

    public wsResponse EndEnterpriseObjec(IAsyncResult asyncResult)
    {
        object[] results = this.EndInvoke(asyncResult);
        return ((wsResponse)(results[0]));
    }

    public void EnterpriseObjecAsync(EnterpriseObjValues EnterpriseObjValues)
    {
        this.EnterpriseObjecAsync(EnterpriseObjValues, null);
    }

    public void EnterpriseObjecAsync(EnterpriseObjValues EnterpriseObjValues, object userState)
    {
        if ((this.EnterpriseObjecOperationCompleted == null))
        {
            this.EnterpriseObjecOperationCompleted = new SendOrPostCallback(this.OnEnterpriseObjecOperationCompleted);
        }
        this.InvokeAsync("EnterpriseObjec", new object[] { EnterpriseObjValues}, this.EnterpriseObjecOperationCompleted, userState);
    }

    private void OnEnterpriseObjecOperationCompleted(object arg)
    {
        if ((this.EnterpriseObjecCompleted != null))
        {
            InvokeCompletedEventArgs invokeArgs = ((InvokeCompletedEventArgs)(arg));
            this.EnterpriseObjecCompleted(this, new EnterpriseObjecCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }
}

Here is the URL to the WSDL. 这是WSDL的URL。 Not sure if this is accessible outside our network. 不知道这是否可以在我们的网络之外访问。

http://sdrsafposent1d:8081/axis/services/grandeFacade?wsdl

And here is the response Fiddler captured. 这是Fiddler捕获的响应。 My other question is with the response I see there is a Java Exception and some ugly jibberish afterwards. 我的另一个问题是响应,我看到有一个Java异常,之后出现了一些难看的杂物。 Can this be causing the issue with the response not being consumed? 这是否可能导致响应不被使用的问题?

2000
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope 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>
  <EnterpriseObjectsResponse xmlns="http://localhost:8180/grandeFacade/services/grandeFacade">
   <EnterpriseObjectsReturn>
    <wsResponse>
     <action>INSERT</action>
     <documentID>1000</documentID>
     <errorMsg></errorMsg>
     <objectName>enca_orden_compra</objectName>
     <stackTrace></stackTrace>
     <status>Not processed</status>
     <transactionID>1</transactionID>
    </wsResponse>
    <wsResponse>
     <action>INSERT</action>
     <documentID>1000</documentID>
     <errorMsg></errorMsg>
     <objectName>det_orden_compra</objectName>
     <stackTrace></stackTrace>
     <status>Not processed</status>
     <transactionID>1</transactionID>
    </wsResponse>
    <wsResponse>
     <action>update</action>
     <documentID>1000</documentID>
     <errorMsg></errorMsg>
     <objectName>enca_orden_compra</objectName>
     <stackTrace></stackTrace>
     <status>Not processed</status>
     <transactionID>1</transactionID>
    </wsResponse>
    <wsResponse>
     <action>update</action>
     <documentID>1000</documentID>
     <errorMsg></errorMsg>
     <objectName>enca_orden_compra</objectName>
     <stackTrace></stackTrace>
     <status>Not processed</status>
     <transactionID>1</transactionID>
    </wsResponse>
    <wsResponse>
     <action>update</action>
     <documentID>1000</documentID>
     <errorMsg></errorMsg>
     <objectName>enca_orden_compra</objectName>
     <stackTrace></stackTrace>
     <status>Not processed</status>
     <transactionID>1</transactionID>
    </wsResponse>
    <wsResponse>
     <action>Informative</action>
     <documentID>Footer</documentID>
     <errorMsg>NULL</errorMsg>
     <objectName></objectName>
     <stackTrace>none
*******************************************************************************
* Object Name: det_orden_compra
* Field Name: Unidades_ordenadas
* Field Value: 1
* Process Step: Getting primary key 
* Possible Error: Incorrect field name or value data from the key
*******************************************************************************
java.lang.NullPointerException</stackTrace>
     <status>error</status>
     <transactionID>

***********************************************************************************************
&lt;EnterpriseObjsValues&gt;
&lt;EnterpriseObjValues&gt;
   &lt;objectName&gt;enca_orden_compra&lt;/objectName&gt;
   &lt;action&gt;INSERT&lt;/action&gt;
   &lt;documentID&gt;1000&lt;/documentID&gt;
   &lt;transactionID&gt;1&lt;/transactionID&gt;
   &lt;source&gt;ORACLE&lt;/source&gt;
   &lt;whereClasue&gt;sucursal = XYZ AND orden = 34567&lt;/whereClasue&gt;
   &lt;objectDetail&gt;
      &lt;item&gt;
         &lt;fieldName&gt;external_id&lt;/fieldName&gt;
         &lt;fieldValue&gt;345888&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;sucursal&lt;/fieldName&gt;
         &lt;fieldValue&gt;XYZ&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;orden&lt;/fieldName&gt;
         &lt;fieldValue&gt;34567&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;proveedor&lt;/fieldName&gt;
         &lt;fieldValue&gt;45454&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;comprador&lt;/fieldName&gt;
         &lt;fieldValue&gt;1001&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;tipo_distribucion&lt;/fieldName&gt;
         &lt;fieldValue&gt;DD&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;order_origin&lt;/fieldName&gt;
         &lt;fieldValue&gt;C&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;document_status&lt;/fieldName&gt;
         &lt;fieldValue&gt;5&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;fecha_orden&lt;/fieldName&gt;
         &lt;fieldValue&gt;3/13/2015 12:53:54 PM&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;fecha_entrada&lt;/fieldName&gt;
         &lt;fieldValue&gt;3/20/2015 12:53:54 PM&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;fecha_cancelacion&lt;/fieldName&gt;
         &lt;fieldValue&gt;3/27/2015 12:53:54 PM&lt;/fieldValue&gt;
      &lt;/item&gt;
   &lt;/objectDetail&gt;
&lt;/EnterpriseObjValues&gt;
&lt;EnterpriseObjValues&gt;
   &lt;objectName&gt;det_orden_compra&lt;/objectName&gt;
   &lt;action&gt;INSERT&lt;/action&gt;
   &lt;documentID&gt;1000&lt;/documentID&gt;
   &lt;transactionID&gt;1&lt;/transactionID&gt;
   &lt;source&gt;ORACLE&lt;/source&gt;
   &lt;whereClasue&gt;sucursal =  AND orden = 34567 AND Articulo = '1'&lt;/whereClasue&gt;
   &lt;objectDetail&gt;
      &lt;item&gt;
         &lt;fieldName&gt;sucursal&lt;/fieldName&gt;
         &lt;fieldValue&gt;&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;orden&lt;/fieldName&gt;
         &lt;fieldValue&gt;34567&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;Articulo&lt;/fieldName&gt;
         &lt;fieldValue&gt;1&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;Unidades_ordenadas&lt;/fieldName&gt;
         &lt;fieldValue&gt;null&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;Costo&lt;/fieldName&gt;
         &lt;fieldValue&gt;13-MAR-15&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;confirmed_quantity&lt;/fieldName&gt;
         &lt;fieldValue&gt;null&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;confirmation_date&lt;/fieldName&gt;
         &lt;fieldValue&gt;3/20/2015 12:53:54 PM&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;confirmation_number&lt;/fieldName&gt;
         &lt;fieldValue&gt;34567&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;document_status&lt;/fieldName&gt;
         &lt;fieldValue&gt;5&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;sequence&lt;/fieldName&gt;
         &lt;fieldValue&gt;4567&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;requisition&lt;/fieldName&gt;
         &lt;fieldValue&gt;1&lt;/fieldValue&gt;
      &lt;/item&gt;
   &lt;/objectDetail&gt;
&lt;/EnterpriseObjValues&gt;
&lt;EnterpriseObjValues&gt;
   &lt;objectName&gt;enca_orden_compra&lt;/objectName&gt;
   &lt;action&gt;update&lt;/action&gt;
   &lt;documentID&gt;1000&lt;/documentID&gt;
   &lt;transactionID&gt;1&lt;/transactionID&gt;
   &lt;source&gt;ORACLE&lt;/source&gt;
   &lt;whereClasue&gt;sucursal =  AND orden = 34567&lt;/whereClasue&gt;
   &lt;objectDetail&gt;
      &lt;item&gt;
         &lt;fieldName&gt;sucursal&lt;/fieldName&gt;
         &lt;fieldValue&gt;&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;orden&lt;/fieldName&gt;
         &lt;fieldValue&gt;34567&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;status_proceso&lt;/fieldName&gt;
         &lt;fieldValue&gt;18&lt;/fieldValue&gt;
      &lt;/item&gt;
   &lt;/objectDetail&gt;
&lt;/EnterpriseObjValues&gt;
&lt;EnterpriseObjValues&gt;
   &lt;objectName&gt;enca_orden_compra&lt;/objectName&gt;
   &lt;action&gt;update&lt;/action&gt;
   &lt;documentID&gt;1000&lt;/documentID&gt;
   &lt;transactionID&gt;1&lt;/transactionID&gt;
   &lt;source&gt;ORACLE&lt;/source&gt;
   &lt;whereClasue&gt;sucursal =  AND orden = 34567&lt;/whereClasue&gt;
   &lt;objectDetail&gt;
      &lt;item&gt;
         &lt;fieldName&gt;sucursal&lt;/fieldName&gt;
         &lt;fieldValue&gt;&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;orden&lt;/fieldName&gt;
         &lt;fieldValue&gt;34567&lt;
554
/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;status_proceso&lt;/fieldName&gt;
         &lt;fieldValue&gt;19&lt;/fieldValue&gt;
      &lt;/item&gt;
   &lt;/objectDetail&gt;
&lt;/EnterpriseObjValues&gt;
&lt;EnterpriseObjValues&gt;
   &lt;objectName&gt;enca_orden_compra&lt;/objectName&gt;
   &lt;action&gt;update&lt;/action&gt;
   &lt;documentID&gt;1000&lt;/documentID&gt;
   &lt;transactionID&gt;1&lt;/transactionID&gt;
   &lt;source&gt;ORACLE&lt;/source&gt;
   &lt;whereClasue&gt;sucursal =  AND orden = 34567&lt;/whereClasue&gt;
   &lt;objectDetail&gt;
      &lt;item&gt;
         &lt;fieldName&gt;sucursal&lt;/fieldName&gt;
         &lt;fieldValue&gt;&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;orden&lt;/fieldName&gt;
         &lt;fieldValue&gt;34567&lt;/fieldValue&gt;
      &lt;/item&gt;
      &lt;item&gt;
         &lt;fieldName&gt;status_proceso&lt;/fieldName&gt;
         &lt;fieldValue&gt;3&lt;/fieldValue&gt;
      &lt;/item&gt;
   &lt;/objectDetail&gt;
&lt;/EnterpriseObjValues&gt;
&lt;/EnterpriseObjsValues&gt;

***********************************************************************************************

</transactionID>
    </wsResponse>
   </EnterpriseObjectsReturn>
  </EnterpriseObjectsResponse>
 </soapenv:Body>
</soapenv:Envelope>
0

Here is the block of code that I where I am making the call and capturing the response. 这是我进行呼叫并捕获响应的代码块。

grandeFacadeService grandeFacadeService serv = new grandeFacadeService();
WebServiceResp response = serv.EnterpriseObjects(enterpriseObjValueslist);
wsResponse[] responseArray= response.wsResponse;

The issue turned out to be the xml itself. 问题出在xml本身。 If you look at the xml half way down it looks like their response was decoding the greater than and less than. 如果您半看xml,则看起来他们的响应正在解码大于和小于。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM