locked
call thirty party java web service but always return null RRS feed

  • Question

  • hi

    I call a java web service in my application visual studio 2008 c#, but always return NULL.

    I used Tool Fiddler to monitor the traffic between my client and the web service server, it showed the return is not Null.

    Here is my code, please see if anything I do wrong.

    namespace CanOfficer_THQ_vs_IHQ.TestWebReferenceAppointment {
        using System.Diagnostics;
        using System.Web.Services;
        using System.ComponentModel;
        using System.Web.Services.Protocols;
        using System;
        using System.Xml.Serialization;
        
        
        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Web.Services.WebServiceBindingAttribute(Name="AppointmentServiceSoapBinding", Namespace="http://service.ips.salvationarmy.org/")]
        public partial class AppointmentService : Microsoft.Web.Services3.WebServicesClientProtocol {
            
            private System.Threading.SendOrPostCallback deleteAppOperationCompleted;
            
            private System.Threading.SendOrPostCallback importAppOperationCompleted;
            
            private System.Threading.SendOrPostCallback editAppOperationCompleted;
            
            private bool useDefaultCredentialsSetExplicitly;
            
            /// <remarks/>
            public AppointmentService() {
                this.Url = global::CanOfficer_THQ_vs_IHQ.Properties.Settings.Default.CanOfficer_THQ_vs_IHQ_TestWebReferenceAppointment_AppointmentService;
                if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
                    this.UseDefaultCredentials = true;
                    this.useDefaultCredentialsSetExplicitly = false;
                }
                else {
                    this.useDefaultCredentialsSetExplicitly = true;
                }
            }
            
            public new string Url {
                get {
                    return base.Url;
                }
                set {
                    if ((((this.IsLocalFileSystemWebService(base.Url) == true) 
                                && (this.useDefaultCredentialsSetExplicitly == false)) 
                                && (this.IsLocalFileSystemWebService(value) == false))) {
                        base.UseDefaultCredentials = false;
                    }
                    base.Url = value;
                }
            }
            
            public new bool UseDefaultCredentials {
                get {
                    return base.UseDefaultCredentials;
                }
                set {
                    base.UseDefaultCredentials = value;
                    this.useDefaultCredentialsSetExplicitly = true;
                }
            }
            
            /// <remarks/>
            public event deleteAppCompletedEventHandler deleteAppCompleted;
            
            /// <remarks/>
            public event importAppCompletedEventHandler importAppCompleted;
            
            /// <remarks/>
            public event editAppCompletedEventHandler editAppCompleted;
            
            /// <remarks/>
            [System.Web.Services.Protocols.SoapDocumentMethodAttribute(
                "",
                RequestNamespace="http://service.ips.salvationarmy.org/", 
                ResponseNamespace="http://service.ips.salvationarmy.org/", 
                Use=System.Web.Services.Description.SoapBindingUse.Encoded,
                ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
            [return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public string deleteApp([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] int id) {
                object[] results = this.Invoke("deleteApp", new object[] {
                            id});
                return ((string)(results[0]));
            }
            
            /// <remarks/>
            public void deleteAppAsync(int id) {
                this.deleteAppAsync(id, null);
            }
            
            /// <remarks/>
            public void deleteAppAsync(int id, object userState) {
                if ((this.deleteAppOperationCompleted == null)) {
                    this.deleteAppOperationCompleted = new System.Threading.SendOrPostCallback(this.OndeleteAppOperationCompleted);
                }
                this.InvokeAsync("deleteApp", new object[] {
                            id}, this.deleteAppOperationCompleted, userState);
            }
            
            private void OndeleteAppOperationCompleted(object arg) {
                if ((this.deleteAppCompleted != null)) {
                    System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                    this.deleteAppCompleted(this, new deleteAppCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
                }
            }
            
            /// <remarks/>
            [System.Web.Services.Protocols.SoapDocumentMethodAttribute(
                "",
                RequestNamespace="http://service.ips.salvationarmy.org/",
                ResponseNamespace="http://service.ips.salvationarmy.org/", 
                Use=System.Web.Services.Description.SoapBindingUse.Encoded,
                ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
            [return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public string importApp(
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] int person, 
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string name, 
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string territory, 
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string location, 
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] bool primary, 
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] Nullable<System.DateTime> start, 
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] Nullable<System.DateTime> end, 
                [System.Xml.Serialization.XmlElementAttribute("categories", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string[] categories) {
                object[] results = this.Invoke("importApp", new object[] {
                            person,
                            name,
                            territory,
                            location,
                            primary,
                            start,
                            end,
                            categories});
                return ((string)(results[0]));
            }
            
            /// <remarks/>
            public void importAppAsync(int person, string name, string territory, string location, bool primary, Nullable<System.DateTime> start, Nullable<System.DateTime> end, string[] categories) {
                this.importAppAsync(person, name, territory, location, primary, start, end, categories, null);
            }
            
            /// <remarks/>
            public void importAppAsync(int person, string name, string territory, string location, bool primary, Nullable<System.DateTime> start, Nullable<System.DateTime> end, string[] categories, object userState) {
                if ((this.importAppOperationCompleted == null)) {
                    this.importAppOperationCompleted = new System.Threading.SendOrPostCallback(this.OnimportAppOperationCompleted);
                }
                this.InvokeAsync("importApp", new object[] {
                            person,
                            name,
                            territory,
                            location,
                            primary,
                            start,
                            end,
                            categories}, this.importAppOperationCompleted, userState);
            }
            
            private void OnimportAppOperationCompleted(object arg) {
                if ((this.importAppCompleted != null)) {
                    System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                    this.importAppCompleted(this, new importAppCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
                }
            }
            
            /// <remarks/>
            [System.Web.Services.Protocols.SoapDocumentMethodAttribute(
                "", 
                RequestNamespace="http://service.ips.salvationarmy.org/", 
                ResponseNamespace="http://service.ips.salvationarmy.org/", 
                Use=System.Web.Services.Description.SoapBindingUse.Encoded, 
                ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
            [return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public string editApp(
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] int id, 
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string name, 
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string territory, 
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string location, 
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] bool primary, 
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] Nullable<System.DateTime> start, 
                [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] Nullable<System.DateTime> end, 
                [System.Xml.Serialization.XmlElementAttribute("categories", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string[] categories) {
                object[] results = this.Invoke("editApp", new object[] {
                            id,
                            name,
                            territory,
                            location,
                            primary,
                            start,
                            end,
                            categories});
                return ((string)(results[0]));
            }
            
            /// <remarks/>
            public void editAppAsync(int id, string name, string territory, string location, bool primary, Nullable<System.DateTime> start, Nullable<System.DateTime> end,  string[] categories) {
                this.editAppAsync(id, name, territory, location, primary, start, end, categories, null);
            }
            
            /// <remarks/>
            public void editAppAsync(int id, string name, string territory, string location, bool primary, Nullable<System.DateTime> start, Nullable<System.DateTime> end, string[] categories, object userState) {
                if ((this.editAppOperationCompleted == null)) {
                    this.editAppOperationCompleted = new System.Threading.SendOrPostCallback(this.OneditAppOperationCompleted);
                }
                this.InvokeAsync("editApp", new object[] {
                            id,
                            name,
                            territory,
                            location,
                            primary,
                            start,
                            end,
                            categories}, this.editAppOperationCompleted, userState);
            }
            
            private void OneditAppOperationCompleted(object arg) {
                if ((this.editAppCompleted != null)) {
                    System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                    this.editAppCompleted(this, new editAppCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
                }
            }
            
            /// <remarks/>
            public new void CancelAsync(object userState) {
                base.CancelAsync(userState);
            }
            
            private bool IsLocalFileSystemWebService(string url) {
                if (((url == null) 
                            || (url == string.Empty))) {
                    return false;
                }
                System.Uri wsUri = new System.Uri(url);
                if (((wsUri.Port >= 1024) 
                            && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
                    return true;
                }
                return false;
            }
        }
        
        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
        public delegate void deleteAppCompletedEventHandler(object sender, deleteAppCompletedEventArgs e);
        
        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        public partial class deleteAppCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
            
            private object[] results;
            
            internal deleteAppCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                    base(exception, cancelled, userState) {
                this.results = results;
            }
            
            /// <remarks/>
            public string Result {
                get {
                    this.RaiseExceptionIfNecessary();
                    return ((string)(this.results[0]));
                }
            }
        }
        
        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
        public delegate void importAppCompletedEventHandler(object sender, importAppCompletedEventArgs e);
        
        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        public partial class importAppCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
            
            private object[] results;
            
            internal importAppCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                    base(exception, cancelled, userState) {
                this.results = results;
            }
            
            /// <remarks/>
            public string Result {
                get {
                    this.RaiseExceptionIfNecessary();
                    return ((string)(this.results[0]));
                }
            }
        }
        
        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
        public delegate void editAppCompletedEventHandler(object sender, editAppCompletedEventArgs e);
        
        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        public partial class editAppCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
            
            private object[] results;
            
            internal editAppCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                    base(exception, cancelled, userState) {
                this.results = results;
            }
            
            /// <remarks/>
            public string Result {
                get {
                    this.RaiseExceptionIfNecessary();
                    return ((string)(this.results[0]));
                }
            }
        }
    }


    • Moved by Caillen Friday, September 12, 2014 3:11 AM
    Wednesday, September 3, 2014 2:37 PM

Answers

  • I am going to suggest that you post to the below forum. Hopefully, you'll get help from someone who has consumed Java Web services using the .NET development platform. But I also suggest that you contact the 3rd party vendor too. I doubt that you are the only developer that is using .NET to consume the Java Web service that may have run into programs that the 3rd party vendor has helped.

    http://forums.asp.net/28.aspx/1?WCF+ASMX+and+other+Web+Services

    • Proposed as answer by Caillen Friday, September 12, 2014 3:11 AM
    • Marked as answer by Just Karl Friday, September 19, 2014 8:49 PM
    Friday, September 5, 2014 8:48 PM

All replies

  • You need to make contact with the Java Web service provider and find out how to consume the service or why it's not working for you as expected.

    Wednesday, September 3, 2014 3:25 PM
  • Hi;

    I used Fiddler to monitor the process, and it showed the request sent thru web service worked and returned a value, but in my .Net application the return captured as NULL. Could you please look into the code above and the result from Filddler and see if you can help.

    thank you.

    REQUEST:

    POST https://159.253.140.178/services/AppointmentService HTTP/1.1
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.4252)
    Content-Type: text/xml; charset=utf-8
    SOAPAction: ""
    Host: 159.253.140.178
    Content-Length: 1589
    Expect: 100-continue
    Connection: Keep-Alive
    
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://service.ips.salvationarmy.org/" xmlns:types="http://service.ips.salvationarmy.org/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
    	<soap:Header>
    		<wsse:Security mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    			<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    				<wsse:Username>
    					IPS_Webservice@can.salvationarmy.org
    				</wsse:Username>
    				<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
    					tpi4IPSws!
    				</wsse:Password>
    			</wsse:UsernameToken>
    		</wsse:Security>
    	</soap:Header>
    	<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    		<tns:importApp>
    			<person xsi:type="xsd:int">
    					169275
    			</person>
    			<name xsi:type="xsd:string">
    					Corps Officer (Cahul-Russia) Test12
    			</name>
    			<territory xsi:type="xsd:string">
    					CAN
    			</territory>
    			<location xsi:type="xsd:string">
    					TEST LOCATION 12
    			</location>
    			<primary xsi:type="xsd:boolean">
    					true
    			</primary>
    			<start xsi:type="xsd:dateTime">
    					2013-05-30T00:00:00
    			</start>
    			<end xsi:type="xsd:dateTime">
    					2014-06-04T00:00:00
    			</end>
    			<categories href="#id1" />
    		</tns:importApp>
    		<soapenc:Array id="id1" soapenc:arrayType="xsd:string[1]">
    			<Item>
    					vpsCat1
    			</Item>
    		</soapenc:Array>
    	</soap:Body>
    </soap:Envelope>

    RESPONSE:

    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    Content-Type: text/xml;charset=UTF-8
    Content-Length: 232
    Date: Fri, 05 Sep 2014 19:45:22 GMT
    
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    		<soap:Body>
    				<ns2:importAppResponse xmlns:ns2="http://service.ips.salvationarmy.org/">
    						<return>
    								OK_572463
    						</return>
    				</ns2:importAppResponse>
    		</soap:Body>
    </soap:Envelope>

    Friday, September 5, 2014 8:15 PM
  • I am going to suggest that you post to the below forum. Hopefully, you'll get help from someone who has consumed Java Web services using the .NET development platform. But I also suggest that you contact the 3rd party vendor too. I doubt that you are the only developer that is using .NET to consume the Java Web service that may have run into programs that the 3rd party vendor has helped.

    http://forums.asp.net/28.aspx/1?WCF+ASMX+and+other+Web+Services

    • Proposed as answer by Caillen Friday, September 12, 2014 3:11 AM
    • Marked as answer by Just Karl Friday, September 19, 2014 8:49 PM
    Friday, September 5, 2014 8:48 PM