locked
crossdomain.xml clientaccesspolicy.xml - problems on SAP? RRS feed

  • Question

  •  

    Hi,

    I'm trying to connect Silverlight4 with SAP web service. Web service has no encryption and uses SOAP 1.1. 

    I've already tried Web Client, HTTPrequest and 'Add service reference'. Each method returns the same error: 'Not found' ... but endpoint is ok.. When I enter its address in browser I see soap packet so it works for sure. 

    When I run my application first I see logging window. Then I enter my SAP username and password and after couple of seconds debugger says that file was not found on the server. Before I placed crossdomain.xml and clientaccesspolicy.xml on the server I saw only 'security exception' and there was no logging window, so I though that these files are ok.. but today I tried to debug my program and when I do: 

    MessageBox(response.ToString()) - just to see what is wrong, then I saw an error: 'Invalid cross-thread access'. What now? Where is the problem?

    xml files are placed in the root:

    http://myserver_ip/crossdomain.xml

     and looks like this:

    <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
    <cross-domain-policy>
      <allow-http-request-headers-from domain="*" headers="*"/>
    </cross-domain-policy>
    
    
    
    
    <access-policy>
    
      <cross-domain-access>
    
        <policy>
    
          <allow-from http-request-headers="*">
    
            <domain uri="*"/>
    
          </allow-from>
    
          <grant-to>
    
            <resource path="/" include-subpaths="true"/>
    
          </grant-to>
    
        </policy>
    
      </cross-domain-access>
    
    </access-policy>
     

     what is wrong? Endpoint works fine. I also can use this web service from FLEX. Why Silverlight doesn't work?

    Please help.

    Saturday, December 5, 2009 3:04 PM

Answers

  • Alright.... solved.... I figure out that there cannot be any underscores '_' in web service name................... why?

    Who knows.

    Saturday, December 5, 2009 8:19 PM

All replies

  • Hi "Double"-Eagle,

    the "'Invalid cross-thread access" shouldn't have to do something with the Service itself. Instead it seems that you're accessing UIElements from a Non-UI-Thread. Maybe in a Callback method of the Service? Can you specify the line where the Exception occurs?

    If you're accessing a UIElement, you should marshall the work to the UI-Thread by using Dispatcher.BeginInvoke-Method.

     

    Saturday, December 5, 2009 3:10 PM
  • Thanks for your interest Thomas. Code belove. 'sapService' is service done by 'add service reference'.

     

    private void callService()
    {
    BasicHttpBinding myBinding = new BasicHttpBinding();
    EndpointAddress myEndpoint = new EndpointAddress("http:/ip:8004/sap/bc/srt/rfc/sap/z_check/001/z_check/z_check");
    ChannelFactory factory = new ChannelFactory(myBinding, myEndpoint);
    factory.BeginOpen(new AsyncCallback(onCompleteOpenFactory), factory);
    }

    private void onCompleteOpenFactory(IAsyncResult result)
    {
    IChannelFactory factory =
    (IChannelFactory)result.AsyncState;

    factory.EndOpen(result);

    sapService.z_checkChannel channel =
    factory.CreateChannel(new EndpointAddress("http:/ip:8004/sap/bc/srt/rfc/sap/z_check/001/z_check/z_check"));

    channel.BeginOpen(new AsyncCallback(onCompleteOpenChannel), channel);
    }

    private void onCompleteOpenChannel(IAsyncResult result)
    {
    sapService.z_checkChannel channel = (sapService.z_checkChannel)result.AsyncState;
    channel.EndOpen(result);

    sapService.ZwsBp1 argument = new sapService.ZwsBp1();
    argument.IvUsername = "user";
    sapService.ZwsBpRequest request = new sapService.ZwsBpRequest(argument);
    channel.BeginZwsBp(request, new AsyncCallback(onCompleteSend), channel);
    }

    private void onCompleteSend(IAsyncResult result)
    {
    sapService.z_checkChannel channel = (sapService.z_checkChannel)result.AsyncState;
    try
    {
    MessageBox.Show(result.ToString()); //invalid cross-thread access
    sapService.ZwsBpResponse1 response = channel.EndZwsBp(result); //Not found
    reply.Text = response.ToString();
    channel.BeginClose(new AsyncCallback(closeChannel), channel);
    }
    catch (CommunicationObjectFaultedException)
    {
    MessageBox.Show("Communication error..");
    }
    }

    private void closeChannel(IAsyncResult result)
    {
    sapService.z_checkChannel channel = (sapService.z_checkChannel)result.AsyncState;
    channel.EndClose(result);
    }

      

    Errors are commented in function 'onCompleteSend'. So what do you think about it?

     

    Saturday, December 5, 2009 5:07 PM
  • Alright.... solved.... I figure out that there cannot be any underscores '_' in web service name................... why?

    Who knows.

    Saturday, December 5, 2009 8:19 PM