2

I hoping you guys can help me.

I am a .Net developer using C# code. I have been given the task to call a web service written in Java by my colleague. The first problem we have is he doesn’t speak .Net and I don’t speak Java.

The first question is whether to using a web reference or a service reference. Both seem to work in the sense that my program can find the service and add the reference. But the Service Reference is not exposed in my project. For this reason I went with the Web reference at least for now.

I can set any of the properties and recall them and it works fine. The question I have is how to invoke the method. When I ask my colleague he does not seem to get what I am talking about.

I need the answer if it’s something simply or if I need to ask a question my colleague in a way that a Java person will understand what I’m talking about.

Here is the code I have written:

WebReference.getContactUs myContactUs = new WebReference.getContactUs();

        myContactUs.ContactUsReceived = DateTime.Now;
        myContactUs.FirstName = "Bob";
        myContactUs.LastName = "Avallone";
        DateTime _ThisDateTime = myContactUs.ContactUsReceived;

Here is the code from the wsdl

<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://contactus.nrcme.fmcsa.dot.gov/" xmlns:ns1="http://nrcme.fmcsa.dot.gov/ContactUs/" name="ContactUs" targetNamespace="http://nrcme.fmcsa.dot.gov/ContactUs/" xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <xs:schema targetNamespace="http://nrcme.fmcsa.dot.gov/ContactUs/" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="getContactUs">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="ContactUsReceived" type="xs:dateTime" />
            <xs:element name="FirstName" type="xs:string" />
            <xs:element name="LastName" type="xs:string" />
            <xs:element name="Title" type="xs:string" />
            <xs:element name="Organization" type="xs:string" />
            <xs:element name="Address1" type="xs:string" />
            <xs:element name="Address2" type="xs:string" />
            <xs:element name="City" type="xs:string" />
            <xs:element name="State" type="xs:string" />
            <xs:element name="ZipCode" type="xs:string" />
            <xs:element name="Telephone" type="xs:string" />
            <xs:element minOccurs="0" name="Fax" type="xs:string" />
            <xs:element name="Email" type="xs:string" />
            <xs:element name="EmailConfirm" type="xs:string" />
            <xs:element minOccurs="0" name="Comment" type="xs:string" />
            <xs:element minOccurs="0" name="Question1" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="getContactUsResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="ContactUsReceived" type="xs:dateTime" />
            <xs:element minOccurs="0" name="status" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
  </types>
  <message name="ContactUs_getContactUsResponse">
    <part name="getContactUsResponse" element="ns1:getContactUsResponse" />
  </message>
  <message name="ContactUs_getContactUs">
    <part name="getContactUs" element="ns1:getContactUs" />
  </message>
  <portType name="ContactUs">
    <operation name="getContactUs" parameterOrder="getContactUs">
      <input message="ns1:ContactUs_getContactUs" />
      <output message="ns1:ContactUs_getContactUsResponse" />
    </operation>
  </portType>
  <binding name="ContactUsBinding" type="ns1:ContactUs">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <operation name="getContactUs">
      <soap:operation soapAction="http://nrcme.fmcsa.dot.gov/ContactUs/getContactUs" />
      <input>
        <soap:body use="literal" />
      </input>
      <output>
        <soap:body use="literal" />
      </output>
    </operation>
  </binding>
</definitions>

Thanks in advance, this forum has been great.

1
  • When dealing with two two different platforms such as Java and .Net, you need to make the communication as clear as possible. Your question to the Java developer essential boils down to how to I call the WebService using .Net. That is not something the Java developer will be able to provide you. The Java developer can provide details about the Web Service itself (XML, input, output, etc), however, the details of the libraries to use, etc.. are outside of the service provider's (Java dev) scope and most likely their expertise. Commented Mar 21, 2011 at 21:33

4 Answers 4

1

One of the problems that I see is that the WSDL is making things a little confusing. It defines both the XML data object element name and Web Service operation as 'getContactUs'. I would discuss changing the XML data element from 'getContactUs' to something similar to 'ContactInfo'. If this element changes, you will most likely see that your confusion was with this naming.

Typically you would have a few operations that you would need to perform to execute the web service. The first is to retrieve the WebReference proxy instance for the service. The second is to initialize any input parameters as needed. Finally you would use the proxy class to invoke the service method. I believe you have performed the second step, but you are missing the first step which would give you access to the web service invocation. The service invocation may look something similar to the following depending on you code:

WebReference.ContactUs myService = new WebReference.ContactUs();
...
<result data type> _Response = myService.getContactUs(myContactUs);
...
Sign up to request clarification or add additional context in comments.

1 Comment

Kris, This is what I needed. Thanks, I owe you. Bob
0

It seems that you are calling the service method when you call new WebReference.getContactUs();. If you check the web server logs of the machine running the java service you can verify this, However soap "functions" are defined by the element in that wsdl.

Comments

0

The most important point is to have the correct WSDL for the code you need to call. THis appears to be in order.

I would suggest you start with Storm (http://storm.codeplex.com/) to ensure that the WSDL is correct and do initial testing of the web service. Then I have been told that Visual Studio can import a WSDL and generate client code you can then just invoke, which I would do next.

Comments

0

I've had this problem too. It's caused by .NET's DateTime type being different than the Java-defined web service. Just use string to replace the DateTime with a confirmed datetime format.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.