locked
custom header in biztalk schema RRS feed

  • Question

  • Hi,

    Below is my schema structure of Java webservice(request xml). can someone help me how to generate schema from wsdl(i tried generating using svcutil.exe but port bindings didnt get created). when I am trying to use consuming wizard its throwing an error as "failed to get metadata........". One more challenge is how to pass credentials in the custom headers in schema using biztalk. Please find below xml structure

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://webservice.abc.com/ns/V1">

       <soapenv:Header>
          <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://abs.open.org/wss/2004/01/200401-wss-wssecurity-secext-1.0.xsd">
             <wsse:UsernameToken wsu:Id="UsernameToken-25616143" xmlns:wsu="http://abs.open.org/wss/2004/01/wss-wssecurity-utility-1.0.xsd">
                <wsse:Username>44121</wsse:Username>
                <wsse:Password Type="http://abs.open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Pass123!!!</wsse:Password>
             </wsse:UsernameToken>
          </wsse:Security>
       </soapenv:Header>
       <soapenv:Body>
          <v1:User>
    <v1:Operation>add</v1:Operation>
              <v1:Key>123</v1:Key>
              <v1:Role>C</v1:Role>
              <v1:IsSelfAccount>N</v1:IsSelfAccount>
               <v1:IsEnable>Y</v1:IsEnable>
             <v1:IsEnabled>Y</v1:IsEnabled>
             <v1:Email>test@test.com</v1:Email>
             <v1:Mobile>9999999999</v1:Mobile>
             <v1:Name>ravi b</v1:Name>
             <v1:Street>A street</v1:Street>
             <v1:City>hyd</v1:City>
             <v1:State>Tg</v1:State>
             <v1:Pincode>400033</v1:Pincode>
             <v1:Country>IN</v1:Country>
             <v1:Title>Mr</v1:Title>
             <v1:FirstName>xyz</v1:FirstName>
             <v1:LastName>abc</v1:LastName>
             <v1:CCEmails></v1:CCEmails>
          </v1:User>
       </soapenv:Body>
    </soapenv:Envelope>

    how to send this xml as request to webservice in biztalk


    Regards, vishal




    • Edited by b vishal Thursday, January 19, 2017 5:56 AM
    Friday, January 13, 2017 12:50 PM

Answers

All replies

  • Hi Vishal,

    I think this is the Java web service hosted on Apache web server .

    You can ask the web Server team to share the request and response  schema XSD .I think they can provide you the xsd and you can easily create the request response message from for the services . Once important pointer is the header and for this you might need to create property schema .


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply

    Friday, January 13, 2017 1:10 PM
  • Hi Vishal

    Regarding the custom headers, the WCF adapters lets you set custom SOAP headers. You have to use the WCF.OutboundCustomHeaders property and set the value, so-

    outboundMessageInstance(WCF.OutboundCustomHeaders) = 
    "<headers><add:To xmlns:add="http://www.w3.org/2005/08/addressing">rcvAddr</h:To></headers>"

    Refer below post-

    http://blogical.se/blogs/mikael_sand/archive/2012/07/06/setting-custom-soap-headers-in-the-wcf-adapter.aspx

    In orchestrations-

    https://msdn.microsoft.com/en-us/library/bb246026.aspx?f=255&MSPPError=-2147217396

    In custom pipeline components-

    https://msdn.microsoft.com/en-us/library/bb226475.aspx


    Thanks Arindam


    Friday, January 13, 2017 1:30 PM
    Moderator
  • Hi Vishal,

    It looks like it is WS-Security,

    If yes, then you can use the WSHttpBinding and set the appropriate credentials in the bindings. for WS-Security, you need to use the WCF-WsHttp binding/Adapter. WCF-BasicHttp is only for the simpler scenarios where the WS-* protocols are not needed. The settings you need should be under the Security tab.  I believe you would set the security mode to Message and the message client credential type to userName.  Then, down at the bottom of the screen, click the Edit button to enter the username and password. 

    If it is not WS-Security then you can either:

    1. Implement a WCF behaviour/message interceptor to add the required headers.

    https://dgoins.wordpress.com/2013/06/15/custom-binding-elements-and-custom-behaviors-wont-show-in-biztalk-wcf-custom-adapter/

    2. In your orchestration or pipeline populate the WCF.OutboundHeaders message property with the required Xml. 

    In orchestrations- https://msdn.microsoft.com/en-us/library/bb246026.aspx

    In custom pipeline components- https://msdn.microsoft.com/en-us/library/bb226475.aspx

    http://blogical.se/blogs/mikael_sand/archive/2012/07/06/setting-custom-soap-headers-in-the-wcf-adapter.aspx


    Rachit Sikroria (Microsoft Azure MVP)

    Friday, January 13, 2017 4:45 PM
    Moderator
  • Hi Arindam,

    As per your answer I will be using outboundMessageInstance(WCF.OutboundCustomHeaders).

    But the challenge is here in dev i have userid and password but in production it will change. Can you tell me how to send userid and password dynamically in custom header

    <wsse:UsernameToken wsu:Id="UsernameToken-25616143" xmlns:wsu="http://abs.open.org/wss/2004/01/wss-wssecurity-utility-1.0.xsd">
                <wsse:Username>44121</wsse:Username>
                <wsse:Password Type="http://abs.open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Pass123!!!</wsse:Password>

    Thanks,

    vishal


    Regards, vishal

    Saturday, January 14, 2017 7:08 AM
  • Hi Rachit,

     I will be using outboundMessageInstance(WCF.OutboundCustomHeaders).

    But the challenge is here in dev i have userid and password but in production it will change. Can you tell me how to send userid and password dynamically in custom header

    <wsse:UsernameToken wsu:Id="UsernameToken-25616143" xmlns:wsu="http://abs.open.org/wss/2004/01/wss-wssecurity-utility-1.0.xsd">
                <wsse:Username>44121</wsse:Username>
                <wsse:Password Type="http://abs.open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Pass123!!!</wsse:Password>

    Thanks,

    vishal


    Regards, vishal


    • Edited by b vishal Saturday, January 14, 2017 7:09 AM
    Saturday, January 14, 2017 7:09 AM
  • Hi Vishal

    Actually, you may not need to set the custom SOAP headers as suggested by Rachit earlier. You should first try to set security in the WCF WSHttp adapter.

    If the service is https, use Security Mode = TransportWithMesssageCredential, and Message Client Credential type = user name. You may have to try a few combinations to make it work.

    If the service is http, set the security mode to Message and the message client credential type to userName. Again you may have to try a few combinations.

    Refer-

    http://www.biztalkgurus.com/biztalk_server/biztalk_2006_r2/f/13/t/11082.aspx


    Thanks Arindam



    Saturday, January 14, 2017 8:29 AM
    Moderator
  • Hi Vishal ,

    As been discussed  in previous thread you can store the UserId and password in BizTalk configuration file or SSO store and retrieve the value at run time 

    https://social.msdn.microsoft.com/Forums/en-US/5e5da59e-508c-4774-88d1-32f04e3a06ae/c-code-to-load-xml?forum=biztalkgeneral


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply

    Monday, January 16, 2017 4:48 AM
  • Hi Arindam,

    I tried using Security Mode = TransportWithMesssageCredential, and Message Client Credential type = user name, but i got below error

    A message sent to adapter "WCF-WSHttp" on send port "abcService_RequestResponse" with URI "https://abc.com/websvc/UserManagementServiceV1" is suspended.
     Error details: System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. ---> System.ServiceModel.FaultException: The [action] cannot be processed at the receiver.
       --- End of inner exception stack trace ---

    Server stack trace:
       at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
       at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation operation, EndpointAddress target, Uri via, SecurityToken currentToken, TimeSpan timeout)
       at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan timeout)
       at System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan timeout)
       at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at System.ServiceModel.ICommunicationObject.Open()
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.GetChannel[TChannel](IBaseMessage bizTalkMessage, ChannelFactory`1& cachedFactory)
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.SendMessage(IBaseMessage bizTalkMessage)
     MessageId:  {2BDCE833-4BC4-42C3-87B3-1F260C3FA9A4}
     InstanceID: {EA4DFC07-7756-4321-A786-CAE2902BF352}


    Regards, vishal


    • Edited by b vishal Monday, January 16, 2017 8:48 AM
    Monday, January 16, 2017 8:47 AM
  • Hi Vishal

    Can you turn off "Negotiate service credential" and "Establish security context" options in the Security Tab of the WCF SendPort and try again?

    Also can you call the same service using SOAP UI with these credentials?


    Thanks Arindam


    Monday, January 16, 2017 9:23 AM
    Moderator
  • Hi,

    If i am turning off "Negotiate service credential"  it is asking for "service certificate". ya I am able to call service from SOAP UI.


    Regards, vishal

    Monday, January 16, 2017 9:41 AM
  • Hi,

    I have mentioned the same URL in the soap action header


    Regards, vishal

    Monday, January 16, 2017 9:55 AM
  • Can you just disable  "Establish security context" and check?

    Thanks Arindam

    Monday, January 16, 2017 10:55 AM
    Moderator
  • Hi,

    I did and again got this error.

     An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. ---> System.ServiceModel.FaultException: The [action] cannot be processed at the receiver.
       --- End of inner exception stack trace ---

    Server stack trace:
       at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
       at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation operation, EndpointAddress target, Uri via, SecurityToken currentToken, TimeSpan timeout)
       at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan timeout)
       at System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan timeout)
       at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at System.ServiceModel.ICommunicationObject.Open()
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.GetChannel[TChannel](IBaseMessage bizTalkMessage, ChannelFactory`1& cachedFactory)
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.SendMessage(IBaseMessage bizTalkMessage)
     MessageId:  {248ECD93-38F1-41D3-B0DD-EFC299B5D261}
     InstanceID: {994A5AEA-779B-4C87-8A96-C4524A9126E9}


    Regards, vishal


    • Edited by b vishal Monday, January 16, 2017 12:10 PM
    Monday, January 16, 2017 11:11 AM
  • Hi Arindam,

    I used wshttp adapter but it didnt work. When i added the service reference in c# project following bindings are created in app.config file.

    <endpoint address="http://xxxxxxxxxxxx/websvc/UserManagementServiceV1/"
                    binding="customBinding" bindingConfiguration="UserManagementSoapBinding"
                    contract="ManagmentService.UserManagementPortType" name="UserManagementPortType" />

    service has been implemented using custom bindings. I believe i have to configure using wcf-custom adapter and bindings i have to go for custom bindings. If i am right can you tell me how to configure custom binding. what are the things required..


    Regards, vishal

    Thursday, January 19, 2017 3:06 AM
  • Hi Rachit,

    I used above all, but it didnt work. When i added the service reference in c# project following bindings are created in app.config file.

    <endpoint address="http://xxxxxxxxxxxx/websvc/UserManagementServiceV1/"
                    binding="customBinding" bindingConfiguration="UserManagementSoapBinding"
                    contract="ManagmentService.UserManagementPortType" name="UserManagementPortType" />

     I believe i have to configure using wcf-custom adapter and bindings i have to go for custom bindings. If i am right can you tell me how to configure custom binding. what are the things required.


    Regards, vishal

    Thursday, January 19, 2017 3:10 AM
  • Can you call the service from the C# project?

    Can you share the entire custombinding section from the app.config file?


    Thanks Arindam

    Thursday, January 19, 2017 4:14 AM
    Moderator
  • Hi,

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
        </startup>
        <system.serviceModel>
            <bindings>
                <customBinding>
                    <binding name="UserManagementSoapBinding">
                        <textMessageEncoding messageVersion="Soap11" />
                        <httpTransport />
                    </binding>
                </customBinding>
            </bindings>
            <client>
                <endpoint address="http://xxxxxxxxxxxxxx/websvc/UserManagementServiceV1/"
                    binding="customBinding" bindingConfiguration="UserManagementSoapBinding"
                    contract="UserManagementWebService.UserManagementPortType" name="UserManagementPortType"/>
            </client>
        </system.serviceModel>
    </configuration>

     client.ClientCredentials.UserName.UserName = "1244";
    client.ClientCredentials.UserName.Password = "Pass@123!!!";

    Unable to call the service


    Regards, vishal


    • Edited by b vishal Thursday, January 19, 2017 5:19 AM
    Thursday, January 19, 2017 5:19 AM