locked
WF4 Re-hosted Designer - Send Activity - can't call service with custom type as input parameter RRS feed

  • Question

  • Hello -

    I am trying to call a WCF service with the Send Activity, within my re-hosted designer application.

    As I'm not in visual studio, I can't add a service reference and get the methods into my toolbox. I've set the Endpoint correctly and using basicHttpBinding - also my Action matches my OperationName, and the ServiceContractName follows the {uri}servicePortType convention.

    I can confirm from my WCF service-side logs that I'm getting to my desired method - as long as I don't attempt to send any parameters or message content.

    When I add a parameter, my Send Activity faults with ProtocolException, stating "Server unavailable, please try again.."etc.

    I believe this is because I have an "int" parameter defined in the WSDL, and I can only define a parameter in the Send Activity as Int32.

    Calling the service from SOAP UI, or a Visual Studio project is no problem (I know it works).

    Any help would be greatly appreciated!

    -James

    Friday, June 22, 2012 9:47 PM

Answers

  • Hi,

    You can run svcutil command against your service, check the generated messageContract type. It looks like:

    [System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
    public partial class GetDataRequest
    {
        
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://schemas.microsoft.com/2003/10/Serialization/", Order=0)]
        public System.Nullable<int> @int;
        
        public GetDataRequest()
        {
        }
        
        public GetDataRequest(System.Nullable<int> @int)
        {
            this.@int = @int;
        }
    }

    In your case, you might consider write a custom activity, expose the service operation inputs and outputs as in/out argument, call the service in the custom activity. Then, you can use this custom activity in sefl-host designer without write code. Hope this helps, thanks.


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by LeoTang Sunday, July 1, 2012 1:18 PM
    Friday, June 29, 2012 6:14 AM

All replies

  • Hi,

    I'd suggest you add a service reference in your workflow project, then it will generate client activities which you can use them to call WCF service.

    How To: Access a Service From a Workflow Application

    http://msdn.microsoft.com/en-us/library/ee523057

    If you want to call the WCF service manually via Send Activity, you'll need to wrap your service operation inputs and outputs in a MessageContract for Send Activity to work. For more information, please refer to:

    Send Activity in WCF Workflow service is not hitting the service hosted on the Client

    http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/b948da44-a0de-4c7c-940d-18cbf55be793

    Thanks.


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, June 25, 2012 7:18 AM
  • Hi Leo - 

    Thanks for your help with this. As I mentioned, I am working on a re-hosted workflow designer application, so I can't add a service reference to my project (I'm not in Visual Studio).

    How would I wrap my service operation inputs and outputs as you mentioned, WITHOUT changing the service definition? There are many clients of this service so changing it is not an option. In your referenced link the author of the "Answer" states you can do this on the client side with "Send Activity":

    ..."So you can instead choose to create these wrappers at the client side (Send activity side) - and then configure the 'ValueType' property of the Send activity to a variable/value of the appropriate MessageContract type"....

    Unfortunately the author doesn't explain how to determine and then set that appropriate MessageContract type?

    Sorry if this seems like a dumb question but I'm not understanding what to do here.

    Kind Regards,

    - James

    Thursday, June 28, 2012 12:42 AM
  • Hi,

    You can run svcutil command against your service, check the generated messageContract type. It looks like:

    [System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
    public partial class GetDataRequest
    {
        
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://schemas.microsoft.com/2003/10/Serialization/", Order=0)]
        public System.Nullable<int> @int;
        
        public GetDataRequest()
        {
        }
        
        public GetDataRequest(System.Nullable<int> @int)
        {
            this.@int = @int;
        }
    }

    In your case, you might consider write a custom activity, expose the service operation inputs and outputs as in/out argument, call the service in the custom activity. Then, you can use this custom activity in sefl-host designer without write code. Hope this helps, thanks.


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by LeoTang Sunday, July 1, 2012 1:18 PM
    Friday, June 29, 2012 6:14 AM