Microsoft Developer Network > Forenhomepage > Windows Communication Foundation > Problem creating proxy for java webservice with svcutil
Stellen Sie eine FrageStellen Sie eine Frage
 

BeantwortetProblem creating proxy for java webservice with svcutil

  • Montag, 12. März 2007 08:50msteinle TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Hello,

    I tried to create a proxy for a java web service using svcutil.exe.
    Svcutil.exe fails with the message
    Error: Cannot import wsdl:portType
    Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter
    Error: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
    XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.it-informatik.de/de/itinformatik/SOAMetaModel/Services/SecurityManager']/wsdl:portType[@name='AccessControl']

    The wsdl is as follows:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <definitions name="de.itinformatik.SOAMetaModel.Services.SecurityManager.AccessControl" targetNamespace="http://www.it-informatik.de/de/itinformatik/SOAMetaModel/Services/SecurityManager"
        xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns2="http://www.it-informatik.de/de/itinformatik/SOAMetaModel/Services/SecurityManager/types"
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.it-informatik.de/de/itinformatik/SOAMetaModel/Services/SecurityManager"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <types>
            <schema targetNamespace="http://www.it-informatik.de/de/itinformatik/SOAMetaModel/Services/SecurityManager/types"
                xmlns="http://www.w3.org/2001/XMLSchema" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
                xmlns:tns="http://www.it-informatik.de/de/itinformatik/SOAMetaModel/Services/SecurityManager/types"
                xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <complexType name="ServiceException">
                    <sequence>
                        <element name="domainClass" nillable="true" type="string" />
                        <element name="message" nillable="true" type="string" />
                    </sequence>
                </complexType>
                <complexType name="InternalException">
                    <complexContent>
                        <extension base="tns:ServiceException">
                            <sequence />
                        </extension>
                    </complexContent>
                </complexType>
                <complexType name="PersistenceException">
                    <complexContent>
                        <extension base="tns:ServiceException">
                            <sequence />
                        </extension>
                    </complexContent>
                </complexType>
                <complexType name="AuthenticationFailedException">
                    <complexContent>
                        <extension base="tns:ServiceException">
                            <sequence />
                        </extension>
                    </complexContent>
                </complexType>
                <complexType name="TransactionException">
                    <complexContent>
                        <extension base="tns:ServiceException">
                            <sequence />
                        </extension>
                    </complexContent>
                </complexType>
                <complexType name="EnlistmentFailedException">
                    <complexContent>
                        <extension base="tns:TransactionException">
                            <sequence />
                        </extension>
                    </complexContent>
                </complexType>
                <complexType name="StringArray">
                    <sequence>
                        <element maxOccurs="unbounded" minOccurs="0" name="content" nillable="true" type="string" />
                    </sequence>
                </complexType>
                <complexType name="BooleanArray">
                    <sequence>
                        <element maxOccurs="unbounded" minOccurs="0" name="content" type="boolean" />
                    </sequence>
                </complexType>
                <element name="PersistenceException" type="tns:PersistenceException" />
                <element name="TransactionException" type="tns:TransactionException" />
                <element name="InternalException" type="tns:InternalException" />
                <element name="EnlistmentFailedException" type="tns:EnlistmentFailedException" />
            </schema>
        </types>
        <message name="TransactionException">
            <part element="ns2:TransactionException" name="TransactionException" />
        </message>
        <message name="AccessControl_isAuthorizedForUseCases">
            <part name="String_1" type="xsd:string" />
            <part name="StringArray_2" type="ns2:StringArray" />
        </message>
        <message name="PersistenceException">
            <part element="ns2:PersistenceException" name="PersistenceException" />
        </message>
        <message name="AccessControl_isAuthorizedForUseCasesResponse">
            <part name="result" type="ns2:BooleanArray" />
        </message>
        <message name="InternalException">
            <part element="ns2:InternalException" name="InternalException" />
        </message>
        <message name="EnlistmentFailedException">
            <part element="ns2:EnlistmentFailedException" name="EnlistmentFailedException" />
        </message>
        <portType name="AccessControl">
            <operation name="isAuthorizedForUseCases" parameterOrder="String_1 StringArray_2">
                <input message="tns:AccessControl_isAuthorizedForUseCases" />
                <output message="tns:AccessControl_isAuthorizedForUseCasesResponse" />
                <fault message="tns:InternalException" name="InternalException" />
                <fault message="tns:PersistenceException" name="PersistenceException" />
                <fault message="tns:TransactionException" name="TransactionException" />
                <fault message="tns:EnlistmentFailedException" name="EnlistmentFailedException" />
            </operation>
        </portType>
        <binding name="AccessControlBinding" type="tns:AccessControl">
            <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
            <operation name="isAuthorizedForUseCases">
                <soap:operation soapAction="" />
                <input>
                    <soap:body namespace="http://www.it-informatik.de/de/itinformatik/SOAMetaModel/Services/SecurityManager" use="literal" />
                </input>
                <output>
                    <soap:body namespace="http://www.it-informatik.de/de/itinformatik/SOAMetaModel/Services/SecurityManager" use="literal" />
                </output>
                <fault name="InternalException">
                    <soap:fault name="InternalException" use="literal" />
                </fault>
                <fault name="PersistenceException">
                    <soap:fault name="PersistenceException" use="literal" />
                </fault>
                <fault name="TransactionException">
                    <soap:fault name="TransactionException" use="literal" />
                </fault>
                <fault name="EnlistmentFailedException">
                    <soap:fault name="EnlistmentFailedException" use="literal" />
                </fault>
            </operation>
        </binding>
        <service name="De.itinformatik.SOAMetaModel.Services.SecurityManager.AccessControl">
            <port binding="tns:AccessControlBinding" name="AccessControlPort">
                <soap:address location="http://it1srv19:8080/SecurityManager/AccessControl" />
            </port>
        </service>
    </definitions>

    Using .NET2.0/WSE3.0, there was no problem to create the proxy.
    Any suggestions?
    Regards, Martin

Antworten

  • Freitag, 16. März 2007 21:11Hao Xu - MSFT TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet
    Sorry, my bad. It turned out to be the differences between XmlSerializer and XmlFormatter. If you use XmlSerializer (use SvcUtil option /serializer:XmlSerializer), it should work fine.

Alle Antworten

  • Montag, 12. März 2007 19:20Quantum00MVPTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Is that error message in German??
  • Dienstag, 13. März 2007 15:27msteinle TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     

    It is in german, the english translation is "Object reference not set to an instance of an object.". The standard message of a NullReferenceException.

  • Freitag, 16. März 2007 17:05Hao Xu - MSFT TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    I don't see the soap:binding element in the AccessControl portType. Could that be the cause? Is it possible for you to update the WSDL and see if it fixes the problem?
  • Freitag, 16. März 2007 17:24msteinle TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     

    I've never seen a portType with soap:binding element. The soap:binding element is in the binding.

    To be sure, I looked at the wsdl of a .NET WSE web service. It does not have a soap:binding element in its portType, but in the wsdl:binding element, just like my java web service.

    Greetings, Martin

  • Freitag, 16. März 2007 21:11Hao Xu - MSFT TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet
    Sorry, my bad. It turned out to be the differences between XmlSerializer and XmlFormatter. If you use XmlSerializer (use SvcUtil option /serializer:XmlSerializer), it should work fine.
  • Montag, 19. März 2007 13:26msteinle TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Thank you for your reply. I tried this, and svcutil completed without exception.
    But now, the generated proxy code does not compile.
    In the generated interface, the method is annotated with some FaultContract attributes, which refer to classes svcutil did not generate.
    The attributes look the following:
        [System.ServiceModel.FaultContractAttribute(typeof(www.itinformatik.de.de1.itinformatik1.SOAMetaModel.Services.SecurityManager.types.InternalException), Action="", Name="InternalException", Namespace="http://www.it-informatik.de/de/itinformatik/SOAMetaModel/Services/SecurityManager" +
            "/types")]
        [System.ServiceModel.FaultContractAttribute(typeof(www.itinformatik.de.de1.itinformatik1.SOAMetaModel.Services.SecurityManager.types.PersistenceException), Action="", Name="PersistenceException", Namespace="http://www.it-informatik.de/de/itinformatik/SOAMetaModel/Services/SecurityManager" +
            "/types")]
        [System.ServiceModel.FaultContractAttribute(typeof(www.itinformatik.de.de1.itinformatik1.SOAMetaModel.Services.SecurityManager.types.TransactionException), Action="", Name="TransactionException", Namespace="http://www.it-informatik.de/de/itinformatik/SOAMetaModel/Services/SecurityManager" +
            "/types")]
        [System.ServiceModel.FaultContractAttribute(typeof(www.itinformatik.de.de1.itinformatik1.SOAMetaModel.Services.SecurityManager.types.EnlistmentFailedException), Action="", Name="EnlistmentFailedException", Namespace="http://www.it-informatik.de/de/itinformatik/SOAMetaModel/Services/SecurityManager" +
            "/types")]

    I had to remove those attributes to make the proxy work.
    Could you tell me if Microsoft is planning to improve svcutil for better support of Java web services?