none
WCF changing the MyFunctionResponse for a Web Service Method RRS feed

  • Question

  • Hello, 

    I have an issue that I can't seem to figure out.  I have the following function and I need to change the response object.

    <OperationContract(Name:="login", Action:="LoginAction", ReplyAction:="DWSS/MyLoginResponse")>
        Function Login(ByVal Username As String, ByVal Password As String) As MyLoginResponse

    The above creates this in the WSDL. 

    <xs:element name="loginResponse">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1" name="MyLoginResponse" type="tns:MyLoginResponse"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>

    How can you, Using VB, change the, what seems to be automatic, wsdl code generation from the login function.

    I would like to change the loginresponse object to contain the the contents of the myloginresponse object. 

    Why does wcf encapsulate the login method response object into another object?

    I am very new to WCF and web services, so if none of this made much sense let me know I will attempt to explain it in a different way.

    Wednesday, October 4, 2017 7:57 PM

All replies

  • I am attempting to make a copy/test bed of a webservice that a client is creating, so the WSDL is set, I just can't seem to get WCF to follow that.  seems like there is a lot of Crap that MS is doing in the background that you don't really have control over. 

    Wednesday, October 4, 2017 9:23 PM
  • Hi VisioDei,

    >>Why does wcf encapsulate the login method response object into another object?

    What do you mean by this?

    Based on your OperationContract, it will return MyLoginResponse. Based on your description, it seems it returns MyLoginResponse object. What do you mean by loginresponse to contain MyLoginResponse object?

    It would be helpful if you could share us a simple demo which could reproduce your issue.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 5, 2017 5:53 AM
  • Function Login(ByVal Username As String, ByVal Password As String) As MyLoginResponse

    <DataContract(Name:="MyLoginResponse")>
    Public Class MyLoginResponse
        <XmlElement()>
        Public AuthToken As String
        <XmlElement()>
        Public accessPermissions As List(Of AccessPermissions)
    End Class

    I would like to see, rather than the return object being LoginResponse object that contains MyLoginResponse.  Simply the loginResponse Object that contains the AuthTokwen and accessPermissions list. 

    EI this is what the wsdl looks like right now. 

    <xs:element name="loginResponse">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1" name="abc" type="tns:MyLoginResponse"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:complexType name="MyLoginResponse">
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1" name="AuthToken" type="xs:string"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" name="accessPermissions" type="tns:AccessPermissions"/>
    </xs:sequence>
    </xs:complexType>

    I need it to look like this. 

    <xs:element name="loginResponse">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1" name="AuthToken" type="xs:string"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" name="accessPermissions" type="tns:AccessPermissions"/>
    </xs:sequence>
    </xs:complexType>

    Thursday, October 5, 2017 5:57 PM
  • Hi VisioDei,

    For custom WCF Wsdl generation, I suggest you refer below links.

    # WCF Extensibility – WSDL Export Extension

    https://blogs.msdn.microsoft.com/carlosfigueira/2011/10/05/wcf-extensibility-wsdl-export-extension/

    # Flatten your WSDL with this Custom ServiceHost for WCF

    https://blogs.msdn.microsoft.com/dotnetinterop/2008/09/23/flatten-your-wsdl-with-this-custom-servicehost-for-wcf/

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, October 6, 2017 6:58 AM
  • Neither of those really help with the changing of the Response object of a web function.

    Can you read the question again?

    I am super new to this whole web service stuff, if this is not possible in VB or C# then why is it possible in Java and php?

    Tuesday, October 10, 2017 6:47 PM
  • Hi VisioDei,

    >> if this is not possible in VB or C# then why is it possible in Java and php?

    C# or VB is different technology from Java or php. They are following different standards.

    >> the changing of the Response object of a web function

    What do you want to change, Web Service or WSDL?

    In my option, it is possible to custom the WSDL.

    What have you tried by following previous links and what result do you get?

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, October 11, 2017 3:11 AM
  • >> C# or VB is different technology from Java or php. They are following different standards.

    They follow different standards? isn't the idea behind SOAP and WSDL is that there is a standard to be followed for all languages?  I thought these were created so that web service functions would be language independent.

    Friday, October 20, 2017 1:05 PM
  • Hi VisioDei,

    The different standards in my post means C# and Java use different standards to analyze the same WSDL to generate client code. I do not mean they follow different WSDL standards.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 23, 2017 6:40 AM